Improve variable names.
This commit is contained in:
parent
328b8649d8
commit
bed72ccf14
@ -6601,22 +6601,22 @@ MessagesManager::Dialog *MessagesManager::get_service_notifications_dialog() {
|
||||
|
||||
void MessagesManager::save_auth_notification_ids() {
|
||||
auto min_date = G()->unix_time() - AUTH_NOTIFICATION_ID_CACHE_TIME;
|
||||
vector<string> ids;
|
||||
vector<string> stored_ids;
|
||||
for (const auto &it : auth_notification_id_date_) {
|
||||
auto date = it.second;
|
||||
if (date < min_date) {
|
||||
continue;
|
||||
}
|
||||
ids.push_back(it.first);
|
||||
ids.push_back(to_string(date));
|
||||
stored_ids.push_back(it.first);
|
||||
stored_ids.push_back(to_string(date));
|
||||
}
|
||||
|
||||
if (ids.empty()) {
|
||||
if (stored_ids.empty()) {
|
||||
G()->td_db()->get_binlog_pmc()->erase("auth_notification_ids");
|
||||
return;
|
||||
}
|
||||
|
||||
G()->td_db()->get_binlog_pmc()->set("auth_notification_ids", implode(ids, ','));
|
||||
G()->td_db()->get_binlog_pmc()->set("auth_notification_ids", implode(stored_ids, ','));
|
||||
}
|
||||
|
||||
void MessagesManager::on_update_service_notification(tl_object_ptr<telegram_api::updateServiceNotification> &&update,
|
||||
@ -13777,13 +13777,13 @@ void MessagesManager::init() {
|
||||
auto auth_notification_ids_string = G()->td_db()->get_binlog_pmc()->get("auth_notification_ids");
|
||||
if (!auth_notification_ids_string.empty()) {
|
||||
VLOG(notifications) << "Loaded auth_notification_ids = " << auth_notification_ids_string;
|
||||
auto ids = full_split(auth_notification_ids_string, ',');
|
||||
CHECK(ids.size() % 2 == 0);
|
||||
auto stored_ids = full_split(auth_notification_ids_string, ',');
|
||||
CHECK(stored_ids.size() % 2 == 0);
|
||||
bool is_changed = false;
|
||||
auto min_date = G()->unix_time() - AUTH_NOTIFICATION_ID_CACHE_TIME;
|
||||
for (size_t i = 0; i < ids.size(); i += 2) {
|
||||
auto date = to_integer_safe<int32>(ids[i + 1]).ok();
|
||||
if (date < min_date || ids[i].empty()) {
|
||||
for (size_t i = 0; i < stored_ids.size(); i += 2) {
|
||||
auto date = to_integer_safe<int32>(stored_ids[i + 1]).ok();
|
||||
if (date < min_date || stored_ids[i].empty()) {
|
||||
is_changed = true;
|
||||
continue;
|
||||
}
|
||||
@ -13791,7 +13791,7 @@ void MessagesManager::init() {
|
||||
is_changed = true;
|
||||
break;
|
||||
}
|
||||
auth_notification_id_date_.emplace(std::move(ids[i]), date);
|
||||
auth_notification_id_date_.emplace(std::move(stored_ids[i]), date);
|
||||
}
|
||||
if (is_changed) {
|
||||
save_auth_notification_ids();
|
||||
|
@ -268,20 +268,20 @@ void NotificationManager::init() {
|
||||
|
||||
auto notification_announcement_ids_string = G()->td_db()->get_binlog_pmc()->get("notification_announcement_ids");
|
||||
if (!notification_announcement_ids_string.empty()) {
|
||||
VLOG(notifications) << "Load announcement ids = " << notification_announcement_ids_string;
|
||||
auto ids = transform(full_split(notification_announcement_ids_string, ','),
|
||||
[](Slice str) { return to_integer_safe<int32>(str).ok(); });
|
||||
CHECK(ids.size() % 2 == 0);
|
||||
VLOG(notifications) << "Load announcement identifiers = " << notification_announcement_ids_string;
|
||||
auto stored_ids = transform(full_split(notification_announcement_ids_string, ','),
|
||||
[](Slice str) { return to_integer_safe<int32>(str).ok(); });
|
||||
CHECK(stored_ids.size() % 2 == 0);
|
||||
bool is_changed = false;
|
||||
auto min_date = G()->unix_time() - ANNOUNCEMENT_ID_CACHE_TIME;
|
||||
for (size_t i = 0; i < ids.size(); i += 2) {
|
||||
auto id = ids[i];
|
||||
auto date = ids[i + 1];
|
||||
if (date < min_date || id == 0) {
|
||||
for (size_t i = 0; i < stored_ids.size(); i += 2) {
|
||||
auto announcement_id = stored_ids[i];
|
||||
auto date = stored_ids[i + 1];
|
||||
if (date < min_date || announcement_id == 0) {
|
||||
is_changed = true;
|
||||
continue;
|
||||
}
|
||||
announcement_id_date_.emplace(id, date);
|
||||
announcement_id_date_.emplace(announcement_id, date);
|
||||
}
|
||||
if (is_changed) {
|
||||
save_announcement_ids();
|
||||
@ -310,24 +310,24 @@ void NotificationManager::init() {
|
||||
|
||||
void NotificationManager::save_announcement_ids() {
|
||||
auto min_date = G()->unix_time() - ANNOUNCEMENT_ID_CACHE_TIME;
|
||||
vector<int32> ids;
|
||||
vector<int32> stored_ids;
|
||||
for (auto &it : announcement_id_date_) {
|
||||
auto id = it.first;
|
||||
auto announcement_id = it.first;
|
||||
auto date = it.second;
|
||||
if (date < min_date) {
|
||||
continue;
|
||||
}
|
||||
ids.push_back(id);
|
||||
ids.push_back(date);
|
||||
stored_ids.push_back(announcement_id);
|
||||
stored_ids.push_back(date);
|
||||
}
|
||||
|
||||
VLOG(notifications) << "Save announcement ids " << ids;
|
||||
if (ids.empty()) {
|
||||
VLOG(notifications) << "Save announcement identifiers " << stored_ids;
|
||||
if (stored_ids.empty()) {
|
||||
G()->td_db()->get_binlog_pmc()->erase("notification_announcement_ids");
|
||||
return;
|
||||
}
|
||||
|
||||
auto notification_announcement_ids_string = implode(transform(ids, to_string<int32>));
|
||||
auto notification_announcement_ids_string = implode(transform(stored_ids, to_string<int32>));
|
||||
G()->td_db()->get_binlog_pmc()->set("notification_announcement_ids", notification_announcement_ids_string);
|
||||
}
|
||||
|
||||
|
@ -418,19 +418,19 @@ void TopDialogManager::on_load_dialogs(GetTopDialogsQuery &&query, vector<Dialog
|
||||
}
|
||||
|
||||
void TopDialogManager::do_get_top_peers() {
|
||||
std::vector<uint64> ids;
|
||||
std::vector<uint64> peer_ids;
|
||||
for (auto &category : by_category_) {
|
||||
for (auto &top_dialog : category.dialogs) {
|
||||
auto dialog_id = top_dialog.dialog_id;
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
ids.push_back(dialog_id.get_user_id().get());
|
||||
peer_ids.push_back(dialog_id.get_user_id().get());
|
||||
break;
|
||||
case DialogType::Chat:
|
||||
ids.push_back(dialog_id.get_chat_id().get());
|
||||
peer_ids.push_back(dialog_id.get_chat_id().get());
|
||||
break;
|
||||
case DialogType::Channel:
|
||||
ids.push_back(dialog_id.get_channel_id().get());
|
||||
peer_ids.push_back(dialog_id.get_channel_id().get());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -441,7 +441,7 @@ void TopDialogManager::do_get_top_peers() {
|
||||
[actor_id = actor_id(this)](Result<telegram_api::object_ptr<telegram_api::contacts_TopPeers>> result) {
|
||||
send_closure(actor_id, &TopDialogManager::on_get_top_peers, std::move(result));
|
||||
});
|
||||
td_->create_handler<GetTopPeersQuery>(std::move(promise))->send(get_vector_hash(ids));
|
||||
td_->create_handler<GetTopPeersQuery>(std::move(promise))->send(get_vector_hash(peer_ids));
|
||||
}
|
||||
|
||||
void TopDialogManager::on_get_top_peers(Result<telegram_api::object_ptr<telegram_api::contacts_TopPeers>> result) {
|
||||
|
Loading…
Reference in New Issue
Block a user