Slice 6: notifications per §15
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
+40
-1
@@ -139,7 +139,46 @@ def append_user_message(
|
||||
""",
|
||||
(thread_id, author_user_id, text, quote),
|
||||
)
|
||||
return cur.lastrowid
|
||||
message_id = cur.lastrowid
|
||||
# §15 chokepoint per Slice 6: chat messages don't flow through the
|
||||
# bot wrapper (no Git write), so the fan-out is anchored here. The
|
||||
# routing is: prior thread authors get personal-direct
|
||||
# chat_reply_to_my_message; RFC watchers get churn-class
|
||||
# chat_message_in_participated_thread. The notify module resolves
|
||||
# the thread's RFC/branch context internally.
|
||||
_fan_out_chat(thread_id, author_user_id, message_id)
|
||||
return message_id
|
||||
|
||||
|
||||
def _fan_out_chat(thread_id: int, author_user_id: int, message_id: int) -> None:
|
||||
from . import notify
|
||||
row = db.conn().execute(
|
||||
"SELECT rfc_slug, branch_name, thread_kind FROM threads WHERE id = ?",
|
||||
(thread_id,),
|
||||
).fetchone()
|
||||
if row is None or not row["rfc_slug"]:
|
||||
return
|
||||
pr_number = None
|
||||
if row["thread_kind"] == "review":
|
||||
pr_row = db.conn().execute(
|
||||
"""
|
||||
SELECT pr_number FROM cached_prs
|
||||
WHERE rfc_slug = ? AND head_branch = ? AND state = 'open'
|
||||
ORDER BY pr_number DESC LIMIT 1
|
||||
""",
|
||||
(row["rfc_slug"], row["branch_name"]),
|
||||
).fetchone()
|
||||
if pr_row:
|
||||
pr_number = pr_row["pr_number"]
|
||||
notify.fan_out_chat_message(
|
||||
actor_user_id=author_user_id,
|
||||
rfc_slug=row["rfc_slug"],
|
||||
branch_name=row["branch_name"] or "main",
|
||||
thread_id=thread_id,
|
||||
message_id=message_id,
|
||||
is_review_thread=(row["thread_kind"] == "review"),
|
||||
pr_number=pr_number,
|
||||
)
|
||||
|
||||
|
||||
def append_assistant_placeholder(*, thread_id: int, model_id: str) -> int:
|
||||
|
||||
Reference in New Issue
Block a user