diff --git a/setup/register.ts b/setup/register.ts index a15e4698b..51f219218 100644 --- a/setup/register.ts +++ b/setup/register.ts @@ -118,6 +118,13 @@ export async function run(args: string[]): Promise { process.exit(4); } + // Chat SDK adapters prefix platform IDs with the channel type + // (e.g. "telegram:123", "discord:guild:channel"). Normalize here so + // the stored ID always matches what the adapter sends at runtime. + if (!parsed.platformId.startsWith(`${parsed.channel}:`)) { + parsed.platformId = `${parsed.channel}:${parsed.platformId}`; + } + log.info('Registering channel', parsed); // Init v2 central DB diff --git a/src/router.ts b/src/router.ts index 89723fc3b..658c117ad 100644 --- a/src/router.ts +++ b/src/router.ts @@ -34,15 +34,7 @@ export interface InboundEvent { */ export async function routeInbound(event: InboundEvent): Promise { // 1. Resolve messaging group - // Adapters send prefixed platform IDs (e.g. "telegram:123") but users may - // register with raw IDs ("123"). Try exact match first, then stripped prefix. let mg = getMessagingGroupByPlatform(event.channelType, event.platformId); - if (!mg) { - const prefix = `${event.channelType}:`; - if (event.platformId.startsWith(prefix)) { - mg = getMessagingGroupByPlatform(event.channelType, event.platformId.slice(prefix.length)); - } - } if (!mg) { // Auto-create messaging group (adapter already decided to forward this)