refactor(channels): share reset message construction across adapters

This commit is contained in:
William Valentin
2026-02-15 22:26:44 -08:00
parent 46538e71a8
commit 393aaf2743
7 changed files with 74 additions and 23 deletions
+4 -7
View File
@@ -17,7 +17,7 @@ import type {
ChannelAdapter,
ChannelStatus,
} from '../types.js';
import { normalizeResetCommandText, splitMessage } from '../utils.js';
import { buildResetInboundMessage, normalizeResetCommandText, splitMessage } from '../utils.js';
import type { PairingManager } from '../pairing.js';
/** Configuration for the WhatsApp channel adapter. */
@@ -313,16 +313,13 @@ export class WhatsAppAdapter implements ChannelAdapter {
// Detect reset command
if (text === '!reset') {
this.messageHandler({
this.messageHandler(buildResetInboundMessage({
id: message.id.id,
channel: 'whatsapp',
senderId: from,
senderName,
text: '!reset',
timestamp: Date.now(),
metadata: { isCommand: true, command: 'reset' },
...(attachments.length > 0 ? { attachments } : {}),
});
attachments,
}));
return;
}