fix: fixed handling of -404

This commit is contained in:
alina 🌸 2024-02-03 22:08:19 +03:00
parent ac3b5df9a0
commit 7036fe1e97
Signed by: teidesu
SSH key fingerprint: SHA256:uNeCpw6aTSU4aIObXLvHfLkDa82HWH9EiOj9AXOIRpI
2 changed files with 12 additions and 7 deletions

View file

@ -155,16 +155,20 @@ export class MtprotoSession {
*/ */
reset(withAuthKey = false): void { reset(withAuthKey = false): void {
if (withAuthKey) { if (withAuthKey) {
this._authKey.reset() this.resetAuthKey()
this._authKeyTemp.reset()
this._authKeyTempSecondary.reset()
} }
clearTimeout(this.current429Timeout) clearTimeout(this.current429Timeout)
this.resetState() this.resetState(withAuthKey)
this.resetLastPing(true) this.resetLastPing(true)
} }
resetAuthKey(): void {
this._authKey.reset()
this._authKeyTemp.reset()
this._authKeyTempSecondary.reset()
}
/** /**
* Reset session state and generate a new session ID. * Reset session state and generate a new session ID.
* *

View file

@ -218,13 +218,13 @@ export class SessionConnection extends PersistentConnection {
} }
// otherwise, 404 must be referencing the perm_key // otherwise, 404 must be referencing the perm_key
this.log.info('transport error 404, reauthorizing')
} }
// there happened a little trolling // there happened a little trolling
this._session.reset(true) this.log.info('transport error 404, reauthorizing')
this._session.resetAuthKey()
this._resetSession()
this.emit('key-change', null) this.emit('key-change', null)
this._authorize()
return return
} }
@ -1290,6 +1290,7 @@ export class SessionConnection extends PersistentConnection {
this._queuedDestroySession.push(this._session._sessionId) this._queuedDestroySession.push(this._session._sessionId)
this._session.resetState(true) this._session.resetState(true)
this._onAllFailed('session reset')
this.reconnect() this.reconnect()
// once we receive new_session_created, all pending messages will be resent. // once we receive new_session_created, all pending messages will be resent.