Fix notification about a new mtproto session.

This commit is contained in:
John Preston 2019-12-02 12:16:15 +03:00
parent eea508066c
commit cbebcb1bc9
2 changed files with 21 additions and 10 deletions

View File

@ -341,16 +341,8 @@ void Account::startMtp() {
_mtp->setUpdatesHandler(::rpcDone([=](
const mtpPrime *from,
const mtpPrime *end) {
auto newSession = MTPNewSession();
auto updates = MTPUpdates();
if (updates.read(from, end)) {
_mtpUpdates.fire(std::move(updates));
} else if (newSession.read(from, end)) {
_mtpNewSessionCreated.fire({});
} else {
return false;
}
return true;
return checkForUpdates(from, end)
|| checkForNewSession(from, end);
}));
_mtp->setGlobalFailHandler(::rpcFail([=](const RPCError &error) {
if (sessionExists()) {
@ -390,6 +382,23 @@ void Account::startMtp() {
_mtpValue = _mtp.get();
}
bool Account::checkForUpdates(const mtpPrime *from, const mtpPrime *end) {
auto updates = MTPUpdates();
if (!updates.read(from, end)) {
return false;
}
_mtpUpdates.fire(std::move(updates));
return true;
}
bool Account::checkForNewSession(const mtpPrime *from, const mtpPrime *end) {
auto newSession = MTPNewSession();
if (!newSession.read(from, end)) {
return false;
}
_mtpNewSessionCreated.fire({});
return true;
}
void Account::logOut() {
if (_loggingOut) {

View File

@ -83,6 +83,8 @@ private:
Settings &&settings);
void watchProxyChanges();
void watchSessionChanges();
bool checkForUpdates(const mtpPrime *from, const mtpPrime *end);
bool checkForNewSession(const mtpPrime *from, const mtpPrime *end);
void destroyMtpKeys(MTP::AuthKeysList &&keys);
void resetAuthorizationKeys();