From 7c95352bc9a7e24754dea975efdaa59c554cdf5c Mon Sep 17 00:00:00 2001 From: escoand Date: Tue, 25 Aug 2020 14:24:22 +0200 Subject: [PATCH] Handle broadcasts as groups in Whatsapp The current way to get the correct JID of a WhatsApp group is to dump all JIDs to the log and grab the right one. This is working for for groups fine but not for broadcast, as they are not print out. According to https://www.npmjs.com/package/@noamalffasy/js-whatsapp we have these possibilities: * Chats: `[country code][phone number]@s.whatsapp.net` * Groups: `[country code][phone number of creator]-[timestamp of group creation]@g.us` * Broadcast Channels: `[timestamp of group creation]@broadcast` But the bridge does currently interprets (and prints) the only second option. --- bridge/whatsapp/whatsapp.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge/whatsapp/whatsapp.go b/bridge/whatsapp/whatsapp.go index 48b140bb..4ca89813 100644 --- a/bridge/whatsapp/whatsapp.go +++ b/bridge/whatsapp/whatsapp.go @@ -184,7 +184,7 @@ func (b *Bwhatsapp) Disconnect() error { } func isGroupJid(identifier string) bool { - return strings.HasSuffix(identifier, "@g.us") || strings.HasSuffix(identifier, "@temp") + return strings.HasSuffix(identifier, "@g.us") || strings.HasSuffix(identifier, "@temp") || strings.HasSuffix(identifier, "@broadcast") } // JoinChannel Join a WhatsApp group specified in gateway config as channel='number-id@g.us' or channel='Channel name'