fix: Use raw SQL UPDATE to set read status without triggering updated… (#31015)

This commit is contained in:
wangxiaolei
2026-01-15 09:51:44 +08:00
committed by GitHub
parent 1dd89a02ea
commit 5008f5e89b

View File

@ -592,9 +592,12 @@ def _get_conversation(app_model, conversation_id):
if not conversation:
raise NotFound("Conversation Not Exists.")
if not conversation.read_at:
conversation.read_at = naive_utc_now()
conversation.read_account_id = current_user.id
db.session.commit()
db.session.execute(
sa.update(Conversation)
.where(Conversation.id == conversation_id, Conversation.read_at.is_(None))
.values(read_at=naive_utc_now(), read_account_id=current_user.id)
)
db.session.commit()
db.session.refresh(conversation)
return conversation