Reregister device after terminate all sessions.
GitOrigin-RevId: 131a94d04370ccd3ed96ec8f5945ff07df4a67fd
This commit is contained in:
parent
c1a201fd7f
commit
22c88fab89
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "td/telegram/AuthManager.h"
|
#include "td/telegram/AuthManager.h"
|
||||||
#include "td/telegram/ConfigShared.h"
|
#include "td/telegram/ConfigShared.h"
|
||||||
|
#include "td/telegram/DeviceTokenManager.h"
|
||||||
#include "td/telegram/FileReferenceManager.h"
|
#include "td/telegram/FileReferenceManager.h"
|
||||||
#include "td/telegram/files/FileManager.h"
|
#include "td/telegram/files/FileManager.h"
|
||||||
#include "td/telegram/files/FileType.h"
|
#include "td/telegram/files/FileType.h"
|
||||||
@ -220,6 +221,7 @@ class ResetAuthorizationsQuery : public Td::ResultHandler {
|
|||||||
|
|
||||||
bool result = result_ptr.move_as_ok();
|
bool result = result_ptr.move_as_ok();
|
||||||
LOG_IF(WARNING, !result) << "Failed to terminate all sessions";
|
LOG_IF(WARNING, !result) << "Failed to terminate all sessions";
|
||||||
|
send_closure(td->device_token_manager_, &DeviceTokenManager::reregister_device);
|
||||||
promise_.set_value(Unit());
|
promise_.set_value(Unit());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,6 +268,16 @@ void DeviceTokenManager::register_device(tl_object_ptr<td_api::DeviceToken> devi
|
|||||||
save_info(token_type);
|
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>> DeviceTokenManager::get_encryption_keys() const {
|
||||||
vector<std::pair<int64, Slice>> result;
|
vector<std::pair<int64, Slice>> result;
|
||||||
for (int32 token_type = 1; token_type < TokenType::SIZE; token_type++) {
|
for (int32 token_type = 1; token_type < TokenType::SIZE; token_type++) {
|
||||||
@ -318,7 +328,7 @@ void DeviceTokenManager::start_up() {
|
|||||||
token.token = serialized.substr(1);
|
token.token = serialized.substr(1);
|
||||||
}
|
}
|
||||||
LOG(INFO) << "GET device token " << token_type << "--->" << token;
|
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;
|
token.state = TokenInfo::State::Register;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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,
|
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);
|
Promise<td_api::object_ptr<td_api::pushReceiverId>> promise);
|
||||||
|
|
||||||
|
void reregister_device();
|
||||||
|
|
||||||
vector<std::pair<int64, Slice>> get_encryption_keys() const;
|
vector<std::pair<int64, Slice>> get_encryption_keys() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user