fix(worker): improve sendMessage error, add session-pool unit tests

This commit is contained in:
2026-05-27 17:14:56 +05:30
parent 0f30af6018
commit 9cdc41e23e
2 changed files with 80 additions and 1 deletions
+4 -1
View File
@@ -42,7 +42,10 @@ export class WhatsAppSessionPool {
async sendMessage(accountId: string, groupJid: string, text: string): Promise<void> {
const sock = this.sessions.get(accountId);
if (!sock) throw new Error(`No active session for account ${accountId}`);
if (!sock) {
const available = Array.from(this.sessions.keys()).join(', ') || 'none';
throw new Error(`No active session for account ${accountId}. Active accounts: [${available}]`);
}
await sock.sendMessage(groupJid, { text });
}