Speculatively update cached channel administrators.
GitOrigin-RevId: b30a7bbf1ec74a446bf77245772236b94be135cb
This commit is contained in:
parent
3d17b1b166
commit
a3b6aca07d
@ -4205,7 +4205,7 @@ void ContactsManager::add_channel_participant(ChannelId channel_id, UserId user_
|
|||||||
return promise.set_error(Status::Error(3, "Not enough rights to invite members to the supergroup chat"));
|
return promise.set_error(Status::Error(3, "Not enough rights to invite members to the supergroup chat"));
|
||||||
}
|
}
|
||||||
|
|
||||||
speculative_add_channel_users(channel_id, DialogParticipantStatus::Member(), old_status);
|
speculative_add_channel_user(channel_id, user_id, DialogParticipantStatus::Member(), old_status);
|
||||||
vector<tl_object_ptr<telegram_api::InputUser>> input_users;
|
vector<tl_object_ptr<telegram_api::InputUser>> input_users;
|
||||||
input_users.push_back(std::move(input_user));
|
input_users.push_back(std::move(input_user));
|
||||||
td_->create_handler<InviteToChannelQuery>(std::move(promise))->send(channel_id, std::move(input_users));
|
td_->create_handler<InviteToChannelQuery>(std::move(promise))->send(channel_id, std::move(input_users));
|
||||||
@ -4365,7 +4365,7 @@ void ContactsManager::promote_channel_participant(ChannelId channel_id, UserId u
|
|||||||
return promise.set_error(Status::Error(3, "User not found"));
|
return promise.set_error(Status::Error(3, "User not found"));
|
||||||
}
|
}
|
||||||
|
|
||||||
speculative_add_channel_users(channel_id, status, old_status);
|
speculative_add_channel_user(channel_id, user_id, status, old_status);
|
||||||
td_->create_handler<EditChannelAdminQuery>(std::move(promise))->send(channel_id, std::move(input_user), status);
|
td_->create_handler<EditChannelAdminQuery>(std::move(promise))->send(channel_id, std::move(input_user), status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4603,7 +4603,7 @@ void ContactsManager::restrict_channel_participant(ChannelId channel_id, UserId
|
|||||||
status = DialogParticipantStatus::Banned(0);
|
status = DialogParticipantStatus::Banned(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
speculative_add_channel_users(channel_id, status, old_status);
|
speculative_add_channel_user(channel_id, user_id, status, old_status);
|
||||||
td_->create_handler<EditChannelBannedQuery>(std::move(promise))->send(channel_id, std::move(input_user), status);
|
td_->create_handler<EditChannelBannedQuery>(std::move(promise))->send(channel_id, std::move(input_user), status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7212,7 +7212,7 @@ void ContactsManager::speculative_add_channel_participants(ChannelId channel_id,
|
|||||||
update_channel_full(channel_full, channel_id);
|
update_channel_full(channel_full, channel_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContactsManager::speculative_add_channel_users(ChannelId channel_id, DialogParticipantStatus status,
|
void ContactsManager::speculative_add_channel_user(ChannelId channel_id, UserId user_id, DialogParticipantStatus status,
|
||||||
DialogParticipantStatus old_status) {
|
DialogParticipantStatus old_status) {
|
||||||
auto c = get_channel(channel_id);
|
auto c = get_channel(channel_id);
|
||||||
if (c != nullptr && c->participant_count != 0 &&
|
if (c != nullptr && c->participant_count != 0 &&
|
||||||
@ -7221,6 +7221,25 @@ void ContactsManager::speculative_add_channel_users(ChannelId channel_id, Dialog
|
|||||||
update_channel(c, channel_id);
|
update_channel(c, channel_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (status.is_administrator() != old_status.is_administrator()) {
|
||||||
|
DialogId dialog_id(channel_id);
|
||||||
|
auto administrators_it = dialog_administrators_.find(dialog_id);
|
||||||
|
if (administrators_it != dialog_administrators_.end()) {
|
||||||
|
auto user_ids = administrators_it->second;
|
||||||
|
auto it = std::find(user_ids.begin(), user_ids.end(), user_id);
|
||||||
|
bool is_found = it != user_ids.end();
|
||||||
|
|
||||||
|
if (status.is_administrator() != is_found) {
|
||||||
|
if (is_found) {
|
||||||
|
user_ids.erase(it);
|
||||||
|
} else {
|
||||||
|
user_ids.push_back(user_id);
|
||||||
|
}
|
||||||
|
on_update_dialog_administrators(dialog_id, std::move(user_ids), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto channel_full = get_channel_full(channel_id);
|
auto channel_full = get_channel_full(channel_id);
|
||||||
if (channel_full == nullptr) {
|
if (channel_full == nullptr) {
|
||||||
return;
|
return;
|
||||||
@ -9135,6 +9154,7 @@ void ContactsManager::on_update_dialog_administrators(DialogId dialog_id, vector
|
|||||||
log_event_store(it->second).as_slice().str(), Auto());
|
log_event_store(it->second).as_slice().str(), Auto());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
dialog_administrators_.erase(dialog_id);
|
||||||
if (G()->parameters().use_chat_info_db) {
|
if (G()->parameters().use_chat_info_db) {
|
||||||
G()->td_db()->get_sqlite_pmc()->erase(get_dialog_administrators_database_key(dialog_id), Auto());
|
G()->td_db()->get_sqlite_pmc()->erase(get_dialog_administrators_database_key(dialog_id), Auto());
|
||||||
}
|
}
|
||||||
|
@ -867,7 +867,7 @@ class ContactsManager : public Actor {
|
|||||||
tl_object_ptr<telegram_api::ExportedChatInvite> &&invite_link_ptr);
|
tl_object_ptr<telegram_api::ExportedChatInvite> &&invite_link_ptr);
|
||||||
void on_update_channel_full_pinned_message(ChannelFull *channel_full, MessageId message_id);
|
void on_update_channel_full_pinned_message(ChannelFull *channel_full, MessageId message_id);
|
||||||
|
|
||||||
void speculative_add_channel_users(ChannelId channel_id, DialogParticipantStatus status,
|
void speculative_add_channel_user(ChannelId channel_id, UserId user_id, DialogParticipantStatus status,
|
||||||
DialogParticipantStatus old_status);
|
DialogParticipantStatus old_status);
|
||||||
|
|
||||||
void invalidate_chat_full(ChatId chat_id);
|
void invalidate_chat_full(ChatId chat_id);
|
||||||
|
Reference in New Issue
Block a user