Skip to content

Commit

Permalink
Update connect failure constants
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Sep 29, 2023
1 parent 69d5ba6 commit d8b84ce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
7 changes: 7 additions & 0 deletions connectionevents.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ func (cli *Client) handleConnectFailure(node *waBinary.Node) {
case reason == 500 && message == "biz vname fetch error":
// These happen for business accounts randomly, also auto-reconnect
}
if reason == 403 {
cli.Log.Debugf(
"Message for 403 connect failure: %s / %s",
ag.OptionalString("logout_message_header"),
ag.OptionalString("logout_message_subtext"),
)
}
if reason.IsLoggedOut() {
cli.Log.Infof("Got %s connect failure, sending LoggedOut event and deleting session", reason)
go cli.dispatchEvent(&events.LoggedOut{OnConnect: true, Reason: reason})
Expand Down
14 changes: 6 additions & 8 deletions types/events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,20 +133,18 @@ func (tb *TemporaryBan) String() string {
type ConnectFailureReason int

const (
ConnectFailureGeneric ConnectFailureReason = 400
ConnectFailureLoggedOut ConnectFailureReason = 401
ConnectFailureTempBanned ConnectFailureReason = 402
ConnectFailureMainDeviceGone ConnectFailureReason = 403
ConnectFailureUnknownLogout ConnectFailureReason = 406
ConnectFailureMainDeviceGone ConnectFailureReason = 403 // this is now called LOCKED in the whatsapp web code
ConnectFailureUnknownLogout ConnectFailureReason = 406 // this is now called BANNED in the whatsapp web code

ConnectFailureClientOutdated ConnectFailureReason = 405
ConnectFailureBadUserAgent ConnectFailureReason = 409

// 400, 500 and 501 are also existing codes, but the meaning is unknown

// 503 doesn't seem to be included in the web app JS with the other codes, and it's very rare,
// but does happen after a 503 stream error sometimes.

ConnectFailureServiceUnavailable ConnectFailureReason = 503
ConnectFailureInternalServerError ConnectFailureReason = 500
ConnectFailureExperimental ConnectFailureReason = 501
ConnectFailureServiceUnavailable ConnectFailureReason = 503
)

var connectFailureReasonMessage = map[ConnectFailureReason]string{
Expand Down

0 comments on commit d8b84ce

Please sign in to comment.