fixed injection watcher

This commit is contained in:
2026-06-11 07:18:19 +03:00
parent 827f9016cd
commit 06e09cd728
7 changed files with 93 additions and 84 deletions
+2 -18
View File
@@ -1,21 +1,5 @@
from sqlalchemy import select
from app.db.base import SessionLocal
from app.db.models import ChatSession, Message
from app.chat.notice_inbox import post_notice_to_latest_chat
def post_chat_notice(content: str) -> None:
db = SessionLocal()
try:
session = db.scalar(
select(ChatSession).order_by(ChatSession.updated_at.desc()).limit(1)
)
if not session:
session = ChatSession(title="Уведомления")
db.add(session)
db.commit()
db.refresh(session)
db.add(Message(session_id=session.id, role="notice", content=content))
db.commit()
finally:
db.close()
post_notice_to_latest_chat(content)