7a04f298d2
- update to latest telegram layer - remove some references to fields in tg.Entities that don't exist in the schema - originally added here: https://github.com/beeper/td/commit/820929062a2ba0104397bc01235ab58a9cff780e - referenced here - https://github.com/mautrix/telegramgo/commit/124f0967ed195b5a380c9bd02e170ada9710dde3 - https://github.com/mautrix/telegramgo/commit/4205047aab2e0639217148b5d125bfaab668bd8e
24 lines
712 B
Go
24 lines
712 B
Go
// Package auth provides authentication on top of tg.Client.
|
|
package auth
|
|
|
|
import (
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/tgerr"
|
|
)
|
|
|
|
// IsKeyUnregistered reports whether err is AUTH_KEY_UNREGISTERED error.
|
|
//
|
|
// Deprecated: use IsUnauthorized.
|
|
func IsKeyUnregistered(err error) bool {
|
|
return tgerr.Is(err, "AUTH_KEY_UNREGISTERED")
|
|
}
|
|
|
|
// IsUnauthorized reports whether err is any 401 UNAUTHORIZED or is a 406
|
|
// NOT_ACCEPTABLE with AUTH_KEY_DUPLICATED.
|
|
//
|
|
// https://core.telegram.org/api/errors#401-unauthorized
|
|
// https://core.telegram.org/api/errors#406-not-acceptable
|
|
func IsUnauthorized(err error) bool {
|
|
return tgerr.IsCode(err, 401) ||
|
|
(tgerr.IsCode(err, 406) && tgerr.Is(err, "AUTH_KEY_DUPLICATED"))
|
|
}
|