Thumbnail

rani/matterbridge.git

Clone URL: https://git.buni.party/rani/matterbridge.git

commit 7f8c2f78c3241644f207bf56e0747821e32a1857 Author: Wim <wim@42.be> Date: Sun Nov 22 21:42:54 2020 +0000 Retry until we have contacts (whatsapp). Fixes #1122 (#1304) diff --git a/bridge/whatsapp/whatsapp.go b/bridge/whatsapp/whatsapp.go index 85df6a8..ae634d6 100644 --- a/bridge/whatsapp/whatsapp.go +++ b/bridge/whatsapp/whatsapp.go @@ -1136 +11312 @@ 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" { @@ -1926 +19812 @@ 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