From ed5dc5ea51cf6991095859681101bb959aff4866 Mon Sep 17 00:00:00 2001 From: Koshkoshinsk <163998153+Koshkoshinsk@users.noreply.github.com> Date: Wed, 15 Apr 2026 07:38:02 +0000 Subject: [PATCH] fix(v2/chat-sdk): project author into flat sender fields for router gate The chat-sdk bridge was emitting inbound messages with a nested author.{userId,fullName,userName} shape, but router.ts:extractAndUpsertUser reads flat content.senderId / sender / senderName. Result: every chat-sdk adapter (telegram, discord, slack, teams, gchat, webex, matrix, resend, imessage, whatsapp-cloud) hit the strict access gate with userId=null and got dropped, even for the registered owner. Project author into the flat fields inside messageToInbound so the bridge matches the contract documented at router.ts:14-17. Native adapters already set these directly. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/channels/chat-sdk-bridge.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/channels/chat-sdk-bridge.ts b/src/channels/chat-sdk-bridge.ts index 885293b46..c6853a974 100644 --- a/src/channels/chat-sdk-bridge.ts +++ b/src/channels/chat-sdk-bridge.ts @@ -121,6 +121,19 @@ export function createChatSdkBridge(config: ChatSdkBridgeConfig): ChannelAdapter if (replyTo) serialized.replyTo = replyTo; } + // Project chat-sdk's nested author into the flat sender fields the router + // expects (see src/router.ts extractAndUpsertUser). Native adapters already + // populate these directly; this brings chat-sdk adapters in line. + const author = serialized.author as + | { userId?: string; fullName?: string; userName?: string } + | undefined; + if (author) { + const name = author.fullName ?? author.userName; + serialized.senderId = author.userId; + serialized.sender = name; + serialized.senderName = name; + } + // Drop raw to save DB space (can be very large) serialized.raw = undefined;