fix(worker): improve sendMessage error, add session-pool unit tests
This commit is contained in:
@@ -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 });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user