fix(slack): stop block-based sender rehydration on assistant message … · openclaw/openclaw@1915b29
vincentkoc
·
2026-04-26
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -187,6 +187,7 @@ Docs: https://docs.openclaw.ai
|
187 | 187 | - Sessions: make `sessions_spawn(mode="session")` errors name usable alternatives when the current channel cannot bind subagent threads. Fixes #67400. (#67790) Thanks @stainlu. |
188 | 188 | - Agents/Claude CLI: pass the OpenClaw system prompt through Claude's prompt-file flag so Windows runs avoid argv length failures without changing system prompt semantics. Fixes #69158. (#69211) Thanks @skylee-01, @cassioanorte, @Syu0, and @Stache73. |
189 | 189 | - Agents/CLI sessions: bind `google-gemini-cli` session auth-epoch to the Google account identity in `~/.gemini/oauth_creds.json`, so Gemini-backed agents resume their conversation after gateway restart instead of minting a fresh session, and stale bindings are invalidated when the authenticated Google account changes. Fixes #70973. (#71076) Thanks @openperf. |
| 190 | +- Slack: stop treating user mentions in assistant-authored message edit blocks as sender attribution, preventing edited bot messages from spoofing a mentioned DM user. (#71700) Thanks @vincentkoc. |
190 | 191 | |
191 | 192 | ## 2026.4.24 |
192 | 193 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -271,6 +271,35 @@ describe("registerSlackMessageEvents", () => {
|
271 | 271 | expect(messageQueueMock).not.toHaveBeenCalled(); |
272 | 272 | }); |
273 | 273 | |
| 274 | +it("drops self-authored message_changed events that only include block user IDs", async () => { |
| 275 | +const { handleSlackMessage } = await invokeRegisteredHandler({ |
| 276 | +eventName: "message", |
| 277 | +overrides: { dmPolicy: "open" }, |
| 278 | +event: { |
| 279 | + ...makeAssistantChangedEvent(), |
| 280 | +message: { |
| 281 | +ts: "123.456", |
| 282 | +user: "U_BOT", |
| 283 | +text: "preview edit with mention", |
| 284 | +blocks: [ |
| 285 | +{ |
| 286 | +type: "rich_text", |
| 287 | +elements: [ |
| 288 | +{ |
| 289 | +type: "rich_text_section", |
| 290 | +elements: [{ type: "user", user_id: "UREAL123" }], |
| 291 | +}, |
| 292 | +], |
| 293 | +}, |
| 294 | +], |
| 295 | +}, |
| 296 | +}, |
| 297 | +}); |
| 298 | + |
| 299 | +expect(handleSlackMessage).not.toHaveBeenCalled(); |
| 300 | +expect(messageQueueMock).not.toHaveBeenCalled(); |
| 301 | +}); |
| 302 | + |
274 | 303 | it("handles channel and group messages via the unified message handler", async () => { |
275 | 304 | const { handler, handleSlackMessage } = createHandlers("message", { |
276 | 305 | dmPolicy: "open", |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -59,31 +59,12 @@ function collectMetadataUserCandidates(
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
62 | | -function collectBlockUserIds(candidates: Set<string>, value: unknown, botUserId: string): void { |
63 | | -if (Array.isArray(value)) { |
64 | | -for (const entry of value) { |
65 | | -collectBlockUserIds(candidates, entry, botUserId); |
66 | | -} |
67 | | -return; |
68 | | -} |
69 | | -const record = asRecord(value); |
70 | | -if (!record) { |
71 | | -return; |
72 | | -} |
73 | | -addUserCandidate(candidates, record.user_id, botUserId); |
74 | | -for (const key of ["elements", "accessory", "fields"]) { |
75 | | -collectBlockUserIds(candidates, record[key], botUserId); |
76 | | -} |
77 | | -} |
78 | | - |
79 | 62 | function resolveAssistantMessageChangedSender(params: { |
80 | | -event: SlackMessageChangedEvent; |
81 | 63 | message?: SlackAssistantMessageRecord; |
82 | 64 | botUserId: string; |
83 | 65 | }): string | undefined { |
84 | 66 | const candidates = new Set<string>(); |
85 | 67 | collectMetadataUserCandidates(candidates, params.message?.metadata, params.botUserId); |
86 | | -collectBlockUserIds(candidates, params.message?.blocks, params.botUserId); |
87 | 68 | return candidates.size === 1 ? [...candidates][0] : undefined; |
88 | 69 | } |
89 | 70 | |
@@ -122,7 +103,6 @@ function resolveAssistantMessageChangedInbound(params: {
|
122 | 103 | return undefined; |
123 | 104 | } |
124 | 105 | const senderId = resolveAssistantMessageChangedSender({ |
125 | | -event: changed, |
126 | 106 | message, |
127 | 107 | botUserId: params.ctx.botUserId, |
128 | 108 | }); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。