mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2024-12-17 02:43:49 +01:00
Move post-connection ping to after chat list times out
This commit is contained in:
parent
aefe63cba5
commit
7c67fe75eb
1 changed files with 15 additions and 8 deletions
23
user.go
23
user.go
|
@ -455,17 +455,13 @@ func (user *User) sendMarkdownBridgeAlert(formatString string, args ...interface
|
|||
}
|
||||
}
|
||||
|
||||
func (user *User) intPostLogin() {
|
||||
defer user.syncWait.Done()
|
||||
user.createCommunity()
|
||||
user.tryAutomaticDoublePuppeting()
|
||||
|
||||
func (user *User) postConnPing() bool {
|
||||
err := user.Conn.AdminTest()
|
||||
if err != nil {
|
||||
user.log.Errorfln("Post-connection ping failed: %v. Disconnecting and then reconnecting after a second", err)
|
||||
sess, disconnectErr := user.Conn.Disconnect()
|
||||
if disconnectErr != nil {
|
||||
user.log.Warnln("Error while disconnecting after failed post-login ping:", disconnectErr)
|
||||
user.log.Warnln("Error while disconnecting after failed post-connection ping:", disconnectErr)
|
||||
} else {
|
||||
user.Session = &sess
|
||||
}
|
||||
|
@ -474,16 +470,27 @@ func (user *User) intPostLogin() {
|
|||
time.Sleep(1 * time.Second)
|
||||
user.tryReconnect(fmt.Sprintf("Post-connection ping failed: %v", err))
|
||||
}()
|
||||
return
|
||||
return false
|
||||
} else {
|
||||
user.log.Debugln("Post-login ping OK")
|
||||
user.log.Debugln("Post-connection ping OK")
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
func (user *User) intPostLogin() {
|
||||
defer user.syncWait.Done()
|
||||
user.createCommunity()
|
||||
user.tryAutomaticDoublePuppeting()
|
||||
|
||||
select {
|
||||
case <-user.chatListReceived:
|
||||
user.log.Debugln("Chat list receive confirmation received in PostLogin")
|
||||
case <-time.After(time.Duration(user.bridge.Config.Bridge.ChatListWait) * time.Second):
|
||||
user.log.Warnln("Timed out waiting for chat list to arrive!")
|
||||
user.postConnPing()
|
||||
return
|
||||
}
|
||||
if !user.postConnPing() {
|
||||
return
|
||||
}
|
||||
select {
|
||||
|
|
Loading…
Reference in a new issue