fix(whatsapp): pass routing ctx to transcribeFirstAudio so echoTransc… · openclaw/openclaw@55e7f5f
hclsys
·
2026-05-10
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -9,6 +9,7 @@ Docs: https://docs.openclaw.ai
|
9 | 9 | ### Fixes |
10 | 10 | |
11 | 11 | - Feishu: auto-thread `message(action="send")` replies inside the topic when the active session is group_topic or group_topic_sender, and propagate `replyInThread` through text, card, and media outbound adapters so topic-scoped sessions no longer post at the group root. Fixes #74903. (#77151) Thanks @ai-hpc. |
| 12 | +- WhatsApp: pass routing context into voice-note transcript echo preflight so echoed transcripts can deliver to the originating chat. Fixes #79778. (#79788) Thanks @hclsys. |
12 | 13 | |
13 | 14 | ## 2026.5.9 |
14 | 15 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -316,6 +316,48 @@ describe("createWebOnMessageHandler audio preflight", () => {
|
316 | 316 | ); |
317 | 317 | }); |
318 | 318 | |
| 319 | +it("passes routing ctx fields to transcribeFirstAudio so echoTranscript can deliver (#79778)", async () => { |
| 320 | +let capturedCtx: unknown; |
| 321 | +transcribeFirstAudioMock.mockImplementation(async ({ ctx }: { ctx: unknown }) => { |
| 322 | +capturedCtx = ctx; |
| 323 | +return "transcribed voice note"; |
| 324 | +}); |
| 325 | +const handler = createWebOnMessageHandler({ |
| 326 | +cfg: { |
| 327 | +channels: { |
| 328 | +whatsapp: { |
| 329 | +ackReaction: { enabled: true }, |
| 330 | +}, |
| 331 | +}, |
| 332 | +} as never, |
| 333 | +verbose: false, |
| 334 | +connectionId: "conn-1", |
| 335 | +maxMediaBytes: 1024 * 1024, |
| 336 | +groupHistoryLimit: 20, |
| 337 | +groupHistories: new Map(), |
| 338 | +groupMemberNames: new Map(), |
| 339 | +echoTracker: makeEchoTracker() as never, |
| 340 | +backgroundTasks: new Set(), |
| 341 | +replyResolver: vi.fn() as never, |
| 342 | +replyLogger: { |
| 343 | +info: () => {}, |
| 344 | +warn: () => {}, |
| 345 | +debug: () => {}, |
| 346 | +error: () => {}, |
| 347 | +} as never, |
| 348 | +baseMentionConfig: {} as never, |
| 349 | +account: { authDir: "/tmp/auth", accountId: "default" }, |
| 350 | +}); |
| 351 | + |
| 352 | +await handler(makeAudioMsg()); |
| 353 | + |
| 354 | +expect(capturedCtx).toMatchObject({ |
| 355 | +Provider: "whatsapp", |
| 356 | +OriginatingTo: "+15550000002", |
| 357 | +From: "+15550000002", |
| 358 | +}); |
| 359 | +}); |
| 360 | + |
319 | 361 | it("does not transcribe group voice when policy gating rejects before mention", async () => { |
320 | 362 | applyGroupGatingMock.mockResolvedValueOnce({ shouldProcess: false }); |
321 | 363 | const handler = createWebOnMessageHandler({ |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -162,6 +162,13 @@ export function createWebOnMessageHandler(params: {
|
162 | 162 | ctx: { |
163 | 163 | MediaPaths: [msg.mediaPath], |
164 | 164 | MediaTypes: msg.mediaType ? [msg.mediaType] : undefined, |
| 165 | +From: msg.from, |
| 166 | +To: msg.to, |
| 167 | +Provider: "whatsapp", |
| 168 | +Surface: "whatsapp", |
| 169 | +OriginatingChannel: "whatsapp", |
| 170 | +OriginatingTo: conversationId, |
| 171 | +AccountId: route.accountId, |
165 | 172 | }, |
166 | 173 | cfg: params.cfg, |
167 | 174 | })) ?? null; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -219,8 +219,15 @@ describe("processMessage audio preflight transcription", () => {
|
219 | 219 | expect(transcribeFirstAudioMock).toHaveBeenCalledWith( |
220 | 220 | expect.objectContaining({ |
221 | 221 | ctx: expect.objectContaining({ |
| 222 | +AccountId: "default", |
| 223 | +From: "+15550000002", |
222 | 224 | MediaPaths: ["/tmp/voice.ogg"], |
223 | 225 | MediaTypes: ["audio/ogg; codecs=opus"], |
| 226 | +OriginatingChannel: "whatsapp", |
| 227 | +OriginatingTo: "+15550000002", |
| 228 | +Provider: "whatsapp", |
| 229 | +Surface: "whatsapp", |
| 230 | +To: "+15550000001", |
224 | 231 | }), |
225 | 232 | }), |
226 | 233 | ); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -243,6 +243,13 @@ export async function processMessage(params: {
|
243 | 243 | ctx: { |
244 | 244 | MediaPaths: [params.msg.mediaPath], |
245 | 245 | MediaTypes: params.msg.mediaType ? [params.msg.mediaType] : undefined, |
| 246 | +From: params.msg.from, |
| 247 | +To: params.msg.to, |
| 248 | +Provider: "whatsapp", |
| 249 | +Surface: "whatsapp", |
| 250 | +OriginatingChannel: "whatsapp", |
| 251 | +OriginatingTo: conversationId, |
| 252 | +AccountId: params.route.accountId, |
246 | 253 | }, |
247 | 254 | cfg: params.cfg, |
248 | 255 | }); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。