From e2f89ec27ee79ef51c271f40d3fdaf42496d066a Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 7 Jun 2023 20:17:14 +0300 Subject: =?UTF-8?q?fixes=20#3417=20(Telegram:=20=D0=BF=D1=80=D0=B8=20?= =?UTF-8?q?=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8=D0=B8=20=D1=83=D1=87?= =?UTF-8?q?=D1=91=D1=82=D0=BD=D0=BE=D0=B9=20=D0=B7=D0=B0=D0=BF=D0=B8=D1=81?= =?UTF-8?q?=D0=B8=20=D1=81=D0=B5=D1=81=D1=81=D0=B8=D1=8F=20=D0=BD=D0=B5=20?= =?UTF-8?q?=D1=83=D0=B4=D0=B0=D0=BB=D1=8F=D0=B5=D1=82=D1=81=D1=8F)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/Telegram/src/auth.cpp | 13 ++++++------- protocols/Telegram/src/proto.cpp | 6 ++++-- protocols/Telegram/src/proto.h | 1 + protocols/Telegram/src/server.cpp | 3 ++- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/protocols/Telegram/src/auth.cpp b/protocols/Telegram/src/auth.cpp index ed82c99d04..53aa8d5c82 100644 --- a/protocols/Telegram/src/auth.cpp +++ b/protocols/Telegram/src/auth.cpp @@ -99,12 +99,12 @@ void CTelegramProto::ProcessAuth(TD::updateAuthorizationState *pObj) break; case TD::authorizationStateWaitTdlibParameters::ID: - if (!m_bUnregister) { - MFileVersion v; - char text[100]; - Miranda_GetFileVersion(&v); - mir_snprintf(text, "%d.%d.%d.%d", v[0], v[1], v[2], v[3]); - + MFileVersion v; + Miranda_GetFileVersion(&v); + + char text[100]; + mir_snprintf(text, "%d.%d.%d.%d", v[0], v[1], v[2], v[3]); + { CMStringW wszPath(GetProtoFolder()); auto *request = new TD::setTdlibParameters(); @@ -119,7 +119,6 @@ void CTelegramProto::ProcessAuth(TD::updateAuthorizationState *pObj) request->enable_storage_optimizer_ = true; SendQuery(request, &CTelegramProto::OnUpdateAuth); } - else LogOut(); break; case TD::authorizationStateWaitPhoneNumber::ID: diff --git a/protocols/Telegram/src/proto.cpp b/protocols/Telegram/src/proto.cpp index c0e92ecc40..1354be1c33 100644 --- a/protocols/Telegram/src/proto.cpp +++ b/protocols/Telegram/src/proto.cpp @@ -182,8 +182,10 @@ void CTelegramProto::OnBuildProtoMenu() void CTelegramProto::OnErase() { - m_bUnregister = true; - ServerThread(0); + if (getByte(DBKEY_AUTHORIZED)) { + m_bUnregister = true; + ServerThread(0); + } DeleteDirectoryTreeW(GetProtoFolder(), false); } diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h index 0e397eca0d..b0d57893d2 100644 --- a/protocols/Telegram/src/proto.h +++ b/protocols/Telegram/src/proto.h @@ -4,6 +4,7 @@ #define DBKEY_ID "id" #define DBKEY_COMPAT "Compatibility" +#define DBKEY_AUTHORIZED "Authorized" #define DBKEY_AVATAR_HASH "AvatarHash" #define DBKEY_AVATAR_TYPE "AvatarType" diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp index c8eba7f5ae..d40b6dc82f 100644 --- a/protocols/Telegram/src/server.cpp +++ b/protocols/Telegram/src/server.cpp @@ -1,4 +1,4 @@ -/* +-/* Copyright (C) 2012-23 Miranda NG team (https://miranda-ng.org) This program is free software; you can redistribute it and/or @@ -74,6 +74,7 @@ void CTelegramProto::OnLoggedIn() } else { m_impl.m_keepAlive.Start(1000); + setByte(DBKEY_AUTHORIZED, 1); SendQuery(new TD::getChats(td::tl::unique_ptr(), 1000)); } -- cgit v1.2.3