From c043eb54aed5f1f3dcf82a2c844b7177555a01e4 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Wed, 8 Nov 2023 17:57:15 -0800 Subject: [PATCH] Use typed entry source instead of raw str to map source to conf in api.py --- src/khoj/routers/api.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/khoj/routers/api.py b/src/khoj/routers/api.py index 6b913351..08596646 100644 --- a/src/khoj/routers/api.py +++ b/src/khoj/routers/api.py @@ -50,6 +50,7 @@ from database.models import ( LocalPdfConfig, LocalPlaintextConfig, KhojUser, + Entry as DbEntry, GithubConfig, NotionConfig, ) @@ -60,12 +61,12 @@ api = APIRouter() logger = logging.getLogger(__name__) -def map_config_to_object(content_source: str): - if content_source == "github": +def map_config_to_object(content_source: DbEntry.EntrySource): + if content_source == DbEntry.EntrySource.GITHUB: return GithubConfig - if content_source == "notion": + if content_source == DbEntry.EntrySource.GITHUB: return NotionConfig - if content_source == "computer": + if content_source == DbEntry.EntrySource.COMPUTER: return "Computer"