From 9d38eadd428d3455fb56f9080e368b03caed087e Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Fri, 24 Feb 2023 04:01:03 -0600 Subject: [PATCH] Return enabled content types via api/config/types API endpoint Simplifies dynamically populating enabled content types for interfaces --- src/khoj/routers/api.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/khoj/routers/api.py b/src/khoj/routers/api.py index 5e748315..6c433cd1 100644 --- a/src/khoj/routers/api.py +++ b/src/khoj/routers/api.py @@ -26,6 +26,17 @@ def get_default_config_data(): return constants.default_config +@api.get("/config/types", response_model=List[str]) +def get_config_types(): + """Get configured content types""" + return [ + search_type.name + for search_type in SearchType + if any(search_type.value == configured_content_type[0] for configured_content_type in state.config.content_type) + or search_type.value in state.config.content_type.plugins.keys() + ] + + @api.get("/config/data", response_model=FullConfig) def get_config_data(): return state.config