refac
This commit is contained in:
1 parent
86b7bf1f7e
commit
90bb94abf9
1 file changed
+7
-5
@@ -3673,7 +3673,7 @@ async def update_automation(
|
|||||||
prompt: Optional[str] = None,
|
prompt: Optional[str] = None,
|
||||||
rrule: Optional[str] = None,
|
rrule: Optional[str] = None,
|
||||||
model_id: Optional[str] = None,
|
model_id: Optional[str] = None,
|
||||||
folder_id: Optional[str] = None,
|
folder_id: Optional[str] = '',
|
||||||
__request__: Request = None,
|
__request__: Request = None,
|
||||||
__user__: dict = None,
|
__user__: dict = None,
|
||||||
) -> str:
|
) -> str:
|
||||||
@@ -3684,8 +3684,8 @@ async def update_automation(
|
|||||||
:param name: New name for the automation (optional)
|
:param name: New name for the automation (optional)
|
||||||
:param prompt: New prompt/instructions (optional)
|
:param prompt: New prompt/instructions (optional)
|
||||||
:param rrule: New iCalendar RRULE schedule string (optional). See create_automation for format examples.
|
:param rrule: New iCalendar RRULE schedule string (optional). See create_automation for format examples.
|
||||||
:param model_id: New model ID to use (optional)
|
:param model_id: New model ID to use (optional); blank values are ignored
|
||||||
:param folder_id: New owner-owned folder ID (optional); pass an empty string to clear
|
:param folder_id: New owner-owned folder ID (optional); omit or pass blank to keep unchanged, pass null to clear
|
||||||
:return: JSON with the updated automation details
|
:return: JSON with the updated automation details
|
||||||
"""
|
"""
|
||||||
if __request__ is None:
|
if __request__ is None:
|
||||||
@@ -3714,13 +3714,15 @@ async def update_automation(
|
|||||||
# Merge provided fields with existing values
|
# Merge provided fields with existing values
|
||||||
new_name = name if name is not None else automation.name
|
new_name = name if name is not None else automation.name
|
||||||
new_prompt = prompt if prompt is not None else automation.data.get('prompt', '')
|
new_prompt = prompt if prompt is not None else automation.data.get('prompt', '')
|
||||||
new_model_id = model_id if model_id is not None else automation.data.get('model_id', '')
|
new_model_id = model_id.strip() if model_id and model_id.strip() else automation.data.get('model_id', '')
|
||||||
new_rrule = rrule if rrule is not None else automation.data.get('rrule', '')
|
new_rrule = rrule if rrule is not None else automation.data.get('rrule', '')
|
||||||
if folder_id is None:
|
if folder_id is None:
|
||||||
|
new_folder_id = None
|
||||||
|
elif not folder_id.strip():
|
||||||
new_folder_id = automation.folder_id
|
new_folder_id = automation.folder_id
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
new_folder_id = await _validate_owned_automation_folder(user_id, folder_id)
|
new_folder_id = await _validate_owned_automation_folder(user_id, folder_id.strip())
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
return JSONCodec.dumps({'error': str(e)})
|
return JSONCodec.dumps({'error': str(e)})
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user