summaryrefslogtreecommitdiffstats
path: root/bridge
diff options
context:
space:
mode:
authorWim <wim@42.be>2020-11-22 21:42:54 +0100
committerGitHub <noreply@github.com>2020-11-22 21:42:54 +0100
commit64b899ac8944f5bd94dfddcefeac8c0f4141be62 (patch)
treebddfb8983c999fc6d27ddde56925764547e26d77 /bridge
parentaa274e5ab7176c83d79fd34dc6a33ba6d841bf5f (diff)
downloadmatterbridge-msglm-64b899ac8944f5bd94dfddcefeac8c0f4141be62.tar.gz
matterbridge-msglm-64b899ac8944f5bd94dfddcefeac8c0f4141be62.tar.bz2
matterbridge-msglm-64b899ac8944f5bd94dfddcefeac8c0f4141be62.zip
Retry until we have contacts (whatsapp). Fixes #1122 (#1304)
Diffstat (limited to 'bridge')
-rw-r--r--bridge/whatsapp/whatsapp.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/bridge/whatsapp/whatsapp.go b/bridge/whatsapp/whatsapp.go
index 85df6a8d..ae634d6a 100644
--- a/bridge/whatsapp/whatsapp.go
+++ b/bridge/whatsapp/whatsapp.go
@@ -113,6 +113,12 @@ func (b *Bwhatsapp) Connect() error {
return fmt.Errorf("error on update of contacts: %v", err)
}
+ // see https://github.com/Rhymen/go-whatsapp/issues/137#issuecomment-480316013
+ for len(b.conn.Store.Contacts) == 0 {
+ b.conn.Contacts() // nolint:errcheck
+ <-time.After(1 * time.Second)
+ }
+
// map all the users
for id, contact := range b.conn.Store.Contacts {
if !isGroupJid(id) && id != "status@broadcast" {
@@ -192,6 +198,12 @@ func isGroupJid(identifier string) bool {
func (b *Bwhatsapp) JoinChannel(channel config.ChannelInfo) error {
byJid := isGroupJid(channel.Name)
+ // see https://github.com/Rhymen/go-whatsapp/issues/137#issuecomment-480316013
+ for len(b.conn.Store.Contacts) == 0 {
+ b.conn.Contacts() // nolint:errcheck
+ <-time.After(1 * time.Second)
+ }
+
// verify if we are member of the given group
if byJid {
// channel.Name specifies static group jID, not the name