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) <noreply@anthropic.com>
This commit is contained in:
Koshkoshinsk
2026-04-15 07:38:02 +00:00
parent db3aa0bf1f
commit ed5dc5ea51
+13
View File
@@ -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;