mautrix / meta

A Matrix-Facebook Messenger and Instagram DM puppeting bridge.
GNU Affero General Public License v3.0
155 stars 11 forks source link

Fixes WhatsApp socket (e2e chats) reconnection on 401 #68

Closed javiercr closed 3 months ago

javiercr commented 3 months ago

When a user log outs the device from the Messenger mobile app for e2e chats, whatsmeow dispatches a events.LoggedOut event rather than a events.ConnectFailure:

case code == "401" && conflictType == "device_removed":
    cli.expectDisconnect()
    cli.Log.Infof("Got device removed stream error, sending LoggedOut event and deleting session")
    go cli.dispatchEvent(&events.LoggedOut{OnConnect: false, Reason: events.ConnectFailureLoggedOut})
        //...

https://github.com/tulir/whatsmeow/blob/main/connectionevents.go#L34-L37

This PR fixes that, so even if the device is removed for e2e chats, we keep the bridge connected to the WA socket.