fix(router): pass isGroup from adapter through to messaging group creation

The router hardcoded is_group=0 when auto-creating messaging groups,
causing channel mentions to be misclassified as DMs. The Chat SDK
bridge knows which handler fired (onDirectMessage vs onNewMention)
so thread the signal through InboundMessage → InboundEvent → router.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
exe.dev user
2026-04-23 12:23:23 +00:00
parent 61ca43d193
commit d121cd1cd6
3 changed files with 6 additions and 1 deletions

View File

@@ -56,6 +56,8 @@ export interface InboundEvent {
* See InboundMessage.isMention for the full explanation. * See InboundMessage.isMention for the full explanation.
*/ */
isMention?: boolean; isMention?: boolean;
/** True when the source is a group/channel thread, false for DMs. */
isGroup?: boolean;
}; };
replyTo?: DeliveryAddress; replyTo?: DeliveryAddress;
} }
@@ -81,6 +83,8 @@ export interface InboundMessage {
* router falls back to text-match against agent_group_name. * router falls back to text-match against agent_group_name.
*/ */
isMention?: boolean; isMention?: boolean;
/** True when the source is a group/channel thread, false for DMs. */
isGroup?: boolean;
} }
/** A file attachment to deliver alongside a message. */ /** A file attachment to deliver alongside a message. */

View File

@@ -85,6 +85,7 @@ async function main(): Promise<void> {
content: JSON.stringify(message.content), content: JSON.stringify(message.content),
timestamp: message.timestamp, timestamp: message.timestamp,
isMention: message.isMention, isMention: message.isMention,
isGroup: message.isGroup,
}, },
}).catch((err) => { }).catch((err) => {
log.error('Failed to route inbound message', { channelType: adapter.channelType, err }); log.error('Failed to route inbound message', { channelType: adapter.channelType, err });

View File

@@ -170,7 +170,7 @@ export async function routeInbound(event: InboundEvent): Promise<void> {
channel_type: event.channelType, channel_type: event.channelType,
platform_id: event.platformId, platform_id: event.platformId,
name: null, name: null,
is_group: 0, is_group: event.message.isGroup ? 1 : 0,
unknown_sender_policy: 'request_approval', unknown_sender_policy: 'request_approval',
denied_at: null, denied_at: null,
created_at: new Date().toISOString(), created_at: new Date().toISOString(),