Drop UserFull cache when phone number privacy is changed.
GitOrigin-RevId: 4ff14b72fa4b903c9358a1a10023e7b5f3775ff8
This commit is contained in:
parent
bbdad2c9e2
commit
8bbc32e21c
@ -6823,6 +6823,14 @@ void ContactsManager::on_update_online_status_privacy() {
|
|||||||
td_->create_handler<GetContactsStatusesQuery>()->send();
|
td_->create_handler<GetContactsStatusesQuery>()->send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContactsManager::on_update_phone_number_privacy() {
|
||||||
|
// all UserFull.need_phone_number_privacy_exception can be outdated now,
|
||||||
|
// so mark all of them as expired
|
||||||
|
for (auto &it : users_full_) {
|
||||||
|
it.second->expires_at = 0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UserId ContactsManager::get_user_id(const tl_object_ptr<telegram_api::User> &user) {
|
UserId ContactsManager::get_user_id(const tl_object_ptr<telegram_api::User> &user) {
|
||||||
CHECK(user != nullptr);
|
CHECK(user != nullptr);
|
||||||
switch (user->get_id()) {
|
switch (user->get_id()) {
|
||||||
|
@ -256,6 +256,8 @@ class ContactsManager : public Actor {
|
|||||||
|
|
||||||
void on_update_online_status_privacy();
|
void on_update_online_status_privacy();
|
||||||
|
|
||||||
|
void on_update_phone_number_privacy();
|
||||||
|
|
||||||
void on_channel_unban_timeout(ChannelId channel_id);
|
void on_channel_unban_timeout(ChannelId channel_id);
|
||||||
|
|
||||||
void check_dialog_username(DialogId dialog_id, const string &username, Promise<CheckDialogUsernameResult> &&promise);
|
void check_dialog_username(DialogId dialog_id, const string &username, Promise<CheckDialogUsernameResult> &&promise);
|
||||||
|
@ -519,23 +519,34 @@ void PrivacyManager::do_update_privacy(UserPrivacySetting user_privacy_setting,
|
|||||||
info.is_synchronized = true;
|
info.is_synchronized = true;
|
||||||
|
|
||||||
if (!(info.rules == privacy_rules)) {
|
if (!(info.rules == privacy_rules)) {
|
||||||
if ((from_update || was_synchronized) && user_privacy_setting.type() == UserPrivacySetting::Type::UserStatus &&
|
if ((from_update || was_synchronized) && !G()->close_flag()) {
|
||||||
!G()->close_flag()) {
|
switch (user_privacy_setting.type()) {
|
||||||
send_closure_later(G()->contacts_manager(), &ContactsManager::on_update_online_status_privacy);
|
case UserPrivacySetting::Type::UserStatus: {
|
||||||
|
send_closure_later(G()->contacts_manager(), &ContactsManager::on_update_online_status_privacy);
|
||||||
|
|
||||||
auto old_restricted = info.rules.get_restricted_user_ids();
|
auto old_restricted = info.rules.get_restricted_user_ids();
|
||||||
auto new_restricted = privacy_rules.get_restricted_user_ids();
|
auto new_restricted = privacy_rules.get_restricted_user_ids();
|
||||||
if (old_restricted != new_restricted) {
|
if (old_restricted != new_restricted) {
|
||||||
// if a user was unrestricted, it is not received from the server anymore
|
// if a user was unrestricted, it is not received from the server anymore
|
||||||
// we need to reget their online status manually
|
// we need to reget their online status manually
|
||||||
std::vector<int32> unrestricted;
|
std::vector<int32> unrestricted;
|
||||||
std::set_difference(old_restricted.begin(), old_restricted.end(), new_restricted.begin(), new_restricted.end(),
|
std::set_difference(old_restricted.begin(), old_restricted.end(), new_restricted.begin(),
|
||||||
std::back_inserter(unrestricted));
|
new_restricted.end(), std::back_inserter(unrestricted));
|
||||||
for (auto &user_id : unrestricted) {
|
for (auto &user_id : unrestricted) {
|
||||||
send_closure_later(G()->contacts_manager(), &ContactsManager::reload_user, UserId(user_id), Promise<Unit>());
|
send_closure_later(G()->contacts_manager(), &ContactsManager::reload_user, UserId(user_id),
|
||||||
|
Promise<Unit>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
case UserPrivacySetting::Type::UserPhoneNumber:
|
||||||
|
send_closure_later(G()->contacts_manager(), &ContactsManager::on_update_phone_number_privacy);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
info.rules = std::move(privacy_rules);
|
info.rules = std::move(privacy_rules);
|
||||||
send_closure(G()->td(), &Td::send_update,
|
send_closure(G()->td(), &Td::send_update,
|
||||||
make_tl_object<td_api::updateUserPrivacySettingRules>(user_privacy_setting.as_td_api(),
|
make_tl_object<td_api::updateUserPrivacySettingRules>(user_privacy_setting.as_td_api(),
|
||||||
|
Reference in New Issue
Block a user