Remove my_id from Global.

This commit is contained in:
levlam 2022-08-18 20:21:40 +03:00
parent 3de61c80f2
commit 26bd2c71b3
7 changed files with 5 additions and 27 deletions

View File

@ -256,7 +256,7 @@ void DeviceTokenManager::register_device(tl_object_ptr<td_api::DeviceToken> devi
} else {
if ((info.state == TokenInfo::State::Reregister || info.state == TokenInfo::State::Sync) && info.token == token &&
info.other_user_ids == input_user_ids && info.is_app_sandbox == is_app_sandbox && encrypt == info.encrypt) {
int64 push_token_id = encrypt ? info.encryption_key_id : G()->get_my_id();
int64 push_token_id = encrypt ? info.encryption_key_id : G()->get_option_integer("my_id");
return promise.set_value(td_api::make_object<td_api::pushReceiverId>(push_token_id));
}
@ -308,7 +308,7 @@ vector<std::pair<int64, Slice>> DeviceTokenManager::get_encryption_keys() const
if (info.encrypt) {
result.emplace_back(info.encryption_key_id, info.encryption_key);
} else {
result.emplace_back(G()->get_my_id(), Slice());
result.emplace_back(G()->get_option_integer("my_id"), Slice());
}
}
}
@ -424,7 +424,7 @@ void DeviceTokenManager::on_result(NetQueryPtr net_query) {
if (info.encrypt) {
push_token_id = info.encryption_key_id;
} else {
push_token_id = G()->get_my_id();
push_token_id = G()->get_option_integer("my_id");
}
}
info.promise.set_value(td_api::make_object<td_api::pushReceiverId>(push_token_id));

View File

@ -384,13 +384,6 @@ class Global final : public ActorContext {
return parameters_;
}
int64 get_my_id() const {
return my_id_;
}
void set_my_id(int64 my_id) {
my_id_ = my_id;
}
int32 get_gc_scheduler_id() const {
return gc_scheduler_id_;
}
@ -530,8 +523,6 @@ class Global final : public ActorContext {
LazySchedulerLocalStorage<unique_ptr<NetQueryCreator>> net_query_creator_;
unique_ptr<NetQueryDispatcher> net_query_dispatcher_;
int64 my_id_ = 0; // hack
static int64 get_location_key(double latitude, double longitude);
FlatHashMap<int64, int64> location_access_hashes_;

View File

@ -2709,7 +2709,7 @@ void NotificationManager::process_push_notification(string payload, Promise<Unit
send_closure(G()->state_manager(), &StateManager::on_online, false);
}
if (receiver_id == 0 || receiver_id == G()->get_my_id()) {
if (receiver_id == 0 || receiver_id == td_->option_manager_->get_option_integer("my_id")) {
auto status = process_push_notification_payload(payload, was_encrypted, promise);
if (status.is_error()) {
if (status.code() == 406 || status.code() == 200) {

View File

@ -380,11 +380,6 @@ void OptionManager::on_option_updated(Slice name) {
}
}
break;
case 'm':
if (name == "my_id") {
G()->set_my_id(get_option_integer(name));
}
break;
case 'n':
if (name == "notification_cloud_delay_ms") {
send_closure(td_->notification_manager_actor_, &NotificationManager::on_notification_cloud_delay_changed);

View File

@ -3681,8 +3681,6 @@ void Td::init(Result<TdDb::OpenedDatabase> r_opened_database) {
init_managers();
G()->set_my_id(G()->get_option_integer("my_id"));
storage_manager_ = create_actor<StorageManager>("StorageManager", create_reference(), G()->get_gc_scheduler_id());
G()->set_storage_manager(storage_manager_.get());

View File

@ -22,10 +22,6 @@ namespace td {
int VERBOSITY_NAME(net_query) = VERBOSITY_NAME(INFO);
int64 NetQuery::get_my_id() {
return G()->get_my_id();
}
void NetQuery::debug(string state, bool may_be_lost) {
may_be_lost_ = may_be_lost;
VLOG(net_query) << *this << " " << tag("state", state);
@ -57,7 +53,7 @@ NetQuery::NetQuery(State state, uint64 id, BufferSlice &&query, BufferSlice &&an
td::unique(chain_ids_);
auto &data = get_data_unsafe();
data.my_id_ = get_my_id();
data.my_id_ = G()->get_option_integer("my_id");
data.start_timestamp_ = data.state_timestamp_ = Time::now();
LOG(INFO) << *this;
if (stats) {

View File

@ -329,8 +329,6 @@ class NetQuery final : public TsListNode<NetQueryDebug> {
source_ = std::move(source);
}
static int64 get_my_id();
static int32 tl_magic(const BufferSlice &buffer_slice);
public: