mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-07 21:29:13 +00:00
Use typed entry source instead of raw str to map source to conf in api.py
This commit is contained in:
@@ -50,6 +50,7 @@ from database.models import (
|
|||||||
LocalPdfConfig,
|
LocalPdfConfig,
|
||||||
LocalPlaintextConfig,
|
LocalPlaintextConfig,
|
||||||
KhojUser,
|
KhojUser,
|
||||||
|
Entry as DbEntry,
|
||||||
GithubConfig,
|
GithubConfig,
|
||||||
NotionConfig,
|
NotionConfig,
|
||||||
)
|
)
|
||||||
@@ -60,12 +61,12 @@ api = APIRouter()
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def map_config_to_object(content_source: str):
|
def map_config_to_object(content_source: DbEntry.EntrySource):
|
||||||
if content_source == "github":
|
if content_source == DbEntry.EntrySource.GITHUB:
|
||||||
return GithubConfig
|
return GithubConfig
|
||||||
if content_source == "notion":
|
if content_source == DbEntry.EntrySource.GITHUB:
|
||||||
return NotionConfig
|
return NotionConfig
|
||||||
if content_source == "computer":
|
if content_source == DbEntry.EntrySource.COMPUTER:
|
||||||
return "Computer"
|
return "Computer"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user