Fix authorization
This commit is contained in:
parent
ae20adac9f
commit
d87bc048ed
1 changed files with 20 additions and 16 deletions
|
@ -291,7 +291,7 @@ class TelegramHelper private constructor() {
|
|||
fun requestAuthorizationState() {
|
||||
client?.send(TdApi.GetAuthorizationState()) { obj ->
|
||||
if (obj is TdApi.AuthorizationState) {
|
||||
onAuthorizationStateUpdated(obj)
|
||||
onAuthorizationStateUpdated(obj, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -689,13 +689,14 @@ class TelegramHelper private constructor() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun onAuthorizationStateUpdated(authorizationState: AuthorizationState?) {
|
||||
private fun onAuthorizationStateUpdated(authorizationState: AuthorizationState?, info: Boolean = false) {
|
||||
val prevAuthState = getTelegramAuthorizationState()
|
||||
if (authorizationState != null) {
|
||||
this.authorizationState = authorizationState
|
||||
}
|
||||
when (this.authorizationState?.constructor) {
|
||||
TdApi.AuthorizationStateWaitTdlibParameters.CONSTRUCTOR -> {
|
||||
if (!info) {
|
||||
log.info("Init tdlib parameters")
|
||||
|
||||
val parameters = TdApi.TdlibParameters()
|
||||
|
@ -712,9 +713,12 @@ class TelegramHelper private constructor() {
|
|||
|
||||
client!!.send(TdApi.SetTdlibParameters(parameters), AuthorizationRequestHandler())
|
||||
}
|
||||
}
|
||||
TdApi.AuthorizationStateWaitEncryptionKey.CONSTRUCTOR -> {
|
||||
if (!info) {
|
||||
client!!.send(TdApi.CheckDatabaseEncryptionKey(), AuthorizationRequestHandler())
|
||||
}
|
||||
}
|
||||
TdApi.AuthorizationStateWaitPhoneNumber.CONSTRUCTOR -> {
|
||||
log.info("Request phone number")
|
||||
telegramAuthorizationRequestHandler?.telegramAuthorizationRequestListener?.onRequestTelegramAuthenticationParameter(PHONE_NUMBER)
|
||||
|
|
Loading…
Reference in a new issue