This commit is contained in:
Timothy Jaeryang Baek committed 2026-08-25 13:18:38 -04:00
1 parent a4738e0459
commit 1c13fedb16
4 files changed
+82 -55

No files matched your search

+8 -18
View File
@@ -339,11 +339,10 @@ async def get_note_chat_by_id(
chat = await Chats.get_internal_chat_by_note_id(note.id, user.id, db=db)
if chat:
log.info('[note-chat] reusing hidden chat note_id=%s chat_id=%s user_id=%s', note.id, chat.id, user.id)
payload = {**(chat.chat or {})}
params = {**(payload.get('params') or {})}
params = {**((chat.chat or {}).get('params') or {})}
changed = False
if params.pop('note_id', None) is not None:
if 'note_id' in params:
del params['note_id']
changed = True
system = (
@@ -356,12 +355,8 @@ async def get_note_chat_by_id(
params['system'] = system
changed = True
if payload.pop('system', None) is not None:
changed = True
payload['params'] = params
if changed:
updated_chat = await Chats.update_chat_by_id(chat.id, payload, db=db, touch=False)
updated_chat = await Chats.update_chat_by_id(chat.id, {'params': params}, db=db, touch=False)
if updated_chat:
return updated_chat
@@ -434,11 +429,10 @@ async def get_note_chats_by_id(
chats = await Chats.get_internal_chats_by_note_id(note.id, user.id, db=db)
normalized_chats = []
for chat in chats:
payload = {**(chat.chat or {})}
params = {**(payload.get('params') or {})}
params = {**((chat.chat or {}).get('params') or {})}
changed = False
if params.pop('note_id', None) is not None:
if 'note_id' in params:
del params['note_id']
changed = True
system = (
@@ -451,12 +445,8 @@ async def get_note_chats_by_id(
params['system'] = system
changed = True
if payload.pop('system', None) is not None:
changed = True
payload['params'] = params
if changed:
chat = await Chats.update_chat_by_id(chat.id, payload, db=db, touch=False) or chat
chat = await Chats.update_chat_by_id(chat.id, {'params': params}, db=db, touch=False) or chat
normalized_chats.append(chat)