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

View File

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