Reregister device after terminate all sessions.

GitOrigin-RevId: 131a94d04370ccd3ed96ec8f5945ff07df4a67fd
This commit is contained in:
levlam 2019-11-17 22:43:10 +03:00
parent c1a201fd7f
commit 22c88fab89
3 changed files with 15 additions and 1 deletions

View File

@ -12,6 +12,7 @@
#include "td/telegram/AuthManager.h"
#include "td/telegram/ConfigShared.h"
#include "td/telegram/DeviceTokenManager.h"
#include "td/telegram/FileReferenceManager.h"
#include "td/telegram/files/FileManager.h"
#include "td/telegram/files/FileType.h"
@ -220,6 +221,7 @@ class ResetAuthorizationsQuery : public Td::ResultHandler {
bool result = result_ptr.move_as_ok();
LOG_IF(WARNING, !result) << "Failed to terminate all sessions";
send_closure(td->device_token_manager_, &DeviceTokenManager::reregister_device);
promise_.set_value(Unit());
}

View File

@ -268,6 +268,16 @@ void DeviceTokenManager::register_device(tl_object_ptr<td_api::DeviceToken> devi
save_info(token_type);
}
void DeviceTokenManager::reregister_device() {
for (int32 token_type = 1; token_type < TokenType::SIZE; token_type++) {
auto &token = tokens_[token_type];
if (token.state == TokenInfo::State::Sync && !token.token.empty()) {
token.state = TokenInfo::State::Register;
}
}
loop();
}
vector<std::pair<int64, Slice>> DeviceTokenManager::get_encryption_keys() const {
vector<std::pair<int64, Slice>> result;
for (int32 token_type = 1; token_type < TokenType::SIZE; token_type++) {
@ -318,7 +328,7 @@ void DeviceTokenManager::start_up() {
token.token = serialized.substr(1);
}
LOG(INFO) << "GET device token " << token_type << "--->" << token;
if (token.state == TokenInfo::State::Sync) {
if (token.state == TokenInfo::State::Sync && !token.token.empty()) {
token.state = TokenInfo::State::Register;
}
}

View File

@ -29,6 +29,8 @@ class DeviceTokenManager : public NetQueryCallback {
void register_device(tl_object_ptr<td_api::DeviceToken> device_token_ptr, vector<int32> other_user_ids,
Promise<td_api::object_ptr<td_api::pushReceiverId>> promise);
void reregister_device();
vector<std::pair<int64, Slice>> get_encryption_keys() const;
private: