This commit is contained in:
Timothy Jaeryang Baek committed 2026-11-30 22:38:50 +04:00
1 parent 0b63d59ee5
commit 2e648b7e58
1 file changed
+7
+7
View File
@@ -4697,6 +4697,7 @@ async def update_automation(
new_triggers = triggers + [t for t in new_triggers if t['type'] == 'webhook']
new_action = automation.data['action']
chat_id = None
if action is not None:
action = TypeAdapter(AutomationActionForm).validate_python(
action.model_dump(exclude_unset=True) if isinstance(action, BaseModel) else action
@@ -4714,6 +4715,8 @@ async def update_automation(
}
if action.type == 'code' and 'args' not in action.model_fields_set:
new_action['args'] = old.get('args')
if 'new_chat' in action.model_fields_set:
chat_id = (built['target'] or {}).get('chat_id')
try:
expires = automation.expires_at if expires_at is None else parse_timer_at(expires_at) if expires_at else None
@@ -4734,6 +4737,10 @@ async def update_automation(
except HTTPException as e:
return JSONCodec.dumps({'error': e.detail})
updated = await Automations.update_by_id(automation_id, form, next_run)
if chat_id:
# A save keeps the chat the runner last used; point it at the one this was asked from.
await Automations.set_target_ref(automation_id, 'chat_id', chat_id)
updated = await Automations.get_by_id(automation_id)
if next_run_at:
try:
await Automations.update_state_by_id(