mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-08 05:39:13 +00:00
Fix automation retrieval validity check
This commit is contained in:
@@ -1839,8 +1839,8 @@ class AutomationAdapters:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def get_automation(user: KhojUser, automation_id: str) -> Job:
|
def get_automation(user: KhojUser, automation_id: str) -> Job:
|
||||||
# Perform validation checks
|
# Perform validation checks
|
||||||
# Check if user is allowed to delete this automation id
|
# Check if user is allowed to retrieve this automation id
|
||||||
if not is_none_or_empty(automation_id) or automation_id.startswith(f"automation_{user.uuid}_"):
|
if is_none_or_empty(automation_id) or not automation_id.startswith(f"automation_{user.uuid}_"):
|
||||||
raise ValueError("Invalid automation id")
|
raise ValueError("Invalid automation id")
|
||||||
# Check if automation with this id exist
|
# Check if automation with this id exist
|
||||||
automation: Job = state.scheduler.get_job(job_id=automation_id)
|
automation: Job = state.scheduler.get_job(job_id=automation_id)
|
||||||
@@ -1852,8 +1852,8 @@ class AutomationAdapters:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
async def aget_automation(user: KhojUser, automation_id: str) -> Job:
|
async def aget_automation(user: KhojUser, automation_id: str) -> Job:
|
||||||
# Perform validation checks
|
# Perform validation checks
|
||||||
# Check if user is allowed to delete this automation id
|
# Check if user is allowed to retrieve this automation id
|
||||||
if not automation_id.startswith(f"automation_{user.uuid}_"):
|
if is_none_or_empty(automation_id) or not automation_id.startswith(f"automation_{user.uuid}_"):
|
||||||
raise ValueError("Invalid automation id")
|
raise ValueError("Invalid automation id")
|
||||||
# Check if automation with this id exist
|
# Check if automation with this id exist
|
||||||
automation: Job = await sync_to_async(state.scheduler.get_job)(job_id=automation_id)
|
automation: Job = await sync_to_async(state.scheduler.get_job)(job_id=automation_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user