fix: normalize platform ID at registration, not router lookup

Channel adapters prefix platform IDs with their channel type
(e.g. "telegram:123"). Normalize in register.ts so the DB always
stores the canonical format. Removes fallback lookup from router.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
gavrielc
2026-04-09 13:41:07 +03:00
parent 9f5c37fc4c
commit a2badbd525
2 changed files with 7 additions and 8 deletions

View File

@@ -34,15 +34,7 @@ export interface InboundEvent {
*/
export async function routeInbound(event: InboundEvent): Promise<void> {
// 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)