Skip to content

Commit

Permalink
Fixes WhatsApp socket (e2e chats) reconnection on 401 (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
javiercr authored May 31, 2024
1 parent c4eadec commit 9557be1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions user.go
Original file line number Diff line number Diff line change
Expand Up @@ -1040,8 +1040,9 @@ func (user *User) e2eeEventHandler(rawEvt any) {
user.BridgeState.Send(user.waState)
go user.sendMarkdownBridgeAlert(context.TODO(), "Error in WhatsApp connection: %s", evt.PermanentDisconnectDescription())
case events.PermanentDisconnect:
cf, ok := evt.(*events.ConnectFailure)
if ok && cf.Reason == events.ConnectFailureLoggedOut && user.canReconnect() {
cf, ok := evt.(*events.LoggedOut)
if ok && cf.Reason == events.ConnectFailureLoggedOut && !cf.OnConnect && user.canReconnect() {
user.WADevice = nil
user.log.Debug().Msg("Doing full reconnect after WhatsApp 401 error")
go user.FullReconnect()
}
Expand Down

0 comments on commit 9557be1

Please sign in to comment.