fix: explicit m.mentions for ticket notifications and roasts (ahead of Synapse 1.164)
Lint / Shell (shellcheck) (push) Successful in 11s
Lint / JS (eslint) (push) Successful in 12s
Lint / Landing page is rendered (matrix (push) Successful in 5s
Lint / No secrets in webhook configs (push) Successful in 5s
Lint / Python (ruff) (push) Successful in 7s
Lint / Secret scan (gitleaks) (push) Successful in 6s
Lint / Shell (shellcheck) (pull_request) Successful in 10s
Lint / JS (eslint) (pull_request) Successful in 9s
Lint / No secrets in webhook configs (pull_request) Successful in 5s
Lint / Python deps (pip-audit) (push) Successful in 43s
Lint / Landing page is rendered (matrix (pull_request) Successful in 4s
Lint / Python (ruff) (pull_request) Successful in 7s
Lint / Secret scan (gitleaks) (pull_request) Successful in 6s
Lint / Python deps (pip-audit) (pull_request) Successful in 39s
Lint / Shell (shellcheck) (push) Successful in 11s
Lint / JS (eslint) (push) Successful in 12s
Lint / Landing page is rendered (matrix (push) Successful in 5s
Lint / No secrets in webhook configs (push) Successful in 5s
Lint / Python (ruff) (push) Successful in 7s
Lint / Secret scan (gitleaks) (push) Successful in 6s
Lint / Shell (shellcheck) (pull_request) Successful in 10s
Lint / JS (eslint) (pull_request) Successful in 9s
Lint / No secrets in webhook configs (pull_request) Successful in 5s
Lint / Python deps (pip-audit) (push) Successful in 43s
Lint / Landing page is rendered (matrix (pull_request) Successful in 4s
Lint / Python (ruff) (pull_request) Successful in 7s
Lint / Secret scan (gitleaks) (pull_request) Successful in 6s
Lint / Python deps (pip-audit) (pull_request) Successful in 39s
Synapse 1.164 turns on MSC4210 by default: the legacy push rules that
pinged when a user ID or display name appeared in the body are removed, so
a message only notifies the users listed in m.mentions.
- hookshot/tinker-tickets.js deliberately pings assignees/watchers
(notify_users) with matrix.to links; those pings would stop. Return
mentions: { user_ids: notifyUsers } (hookshot 7.3.2 v2 transforms
support it).
- matrixbot: send_html takes optional mention_user_ids; !roast mentions the
target when given as a full Matrix ID. Winner announcements stay without
a ping (the player is already in the room).
No @room is sent anywhere. Lotus Chat already sends m.mentions.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
54bdada04d
commit
e1b2c8575c
@@ -2273,7 +2273,9 @@ async def cmd_roast(client: AsyncClient, room_id: str, sender: str, args: str):
|
||||
f'<blockquote>{roast}</blockquote>'
|
||||
f'<sup><em>via {_model_label(CREATIVE_MODEL)}</em></sup>'
|
||||
)
|
||||
await send_html(client, room_id, plain, html)
|
||||
# Ping the person being roasted when they were named by Matrix ID.
|
||||
target_id = target_raw if re.fullmatch(r"@[^\s:]+:[^\s]+", target_raw) else None
|
||||
await send_html(client, room_id, plain, html, mention_user_ids=[target_id] if target_id else None)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
+15
-7
@@ -70,17 +70,25 @@ async def send_text(client: AsyncClient, room_id: str, text: str):
|
||||
return resp
|
||||
|
||||
|
||||
async def send_html(client: AsyncClient, room_id: str, plain: str, html: str):
|
||||
async def send_html(
|
||||
client: AsyncClient, room_id: str, plain: str, html: str, mention_user_ids: list[str] | None = None
|
||||
):
|
||||
logger = logging.getLogger("matrixbot")
|
||||
content = {
|
||||
"msgtype": "m.text",
|
||||
"body": plain,
|
||||
"format": "org.matrix.custom.html",
|
||||
"formatted_body": html,
|
||||
}
|
||||
# Explicit mentions (m.mentions). From Synapse 1.164 a name or user ID in
|
||||
# the body no longer pings anyone (MSC4210), so a message that should
|
||||
# notify someone has to say so.
|
||||
if mention_user_ids:
|
||||
content["m.mentions"] = {"user_ids": mention_user_ids}
|
||||
resp = await _room_send_trusted(
|
||||
client, room_id,
|
||||
message_type="m.room.message",
|
||||
content={
|
||||
"msgtype": "m.text",
|
||||
"body": plain,
|
||||
"format": "org.matrix.custom.html",
|
||||
"formatted_body": html,
|
||||
},
|
||||
content=content,
|
||||
)
|
||||
if not isinstance(resp, RoomSendResponse):
|
||||
logger.error("send_html failed: %s", resp)
|
||||
|
||||
Reference in New Issue
Block a user