Add repair_dialog_action_bar.

GitOrigin-RevId: 4157f18ad20ff09807b59433d86bce04b676fdf2
This commit is contained in:
levlam 2019-10-11 02:32:25 +03:00
parent 56af9f3f3c
commit d17a1734a4
2 changed files with 34 additions and 6 deletions

View File

@ -6440,6 +6440,25 @@ bool MessagesManager::update_dialog_silent_send_message(Dialog *d, bool silent_s
return true; return true;
} }
void MessagesManager::repair_dialog_action_bar(DialogId dialog_id) {
switch (dialog_id.get_type()) {
case DialogType::User:
td_->contacts_manager_->get_user_full(dialog_id.get_user_id(), Auto());
return;
case DialogType::Chat:
case DialogType::Channel:
if (!have_input_peer(dialog_id, AccessRights::Read)) {
return;
}
return td_->create_handler<GetPeerSettingsQuery>(Promise<Unit>())->send(dialog_id);
case DialogType::SecretChat:
case DialogType::None:
default:
UNREACHABLE();
}
}
bool MessagesManager::get_dialog_report_spam_state(DialogId dialog_id, Promise<Unit> &&promise) { bool MessagesManager::get_dialog_report_spam_state(DialogId dialog_id, Promise<Unit> &&promise) {
Dialog *d = get_dialog_force(dialog_id); Dialog *d = get_dialog_force(dialog_id);
if (d == nullptr) { if (d == nullptr) {
@ -6447,11 +6466,6 @@ bool MessagesManager::get_dialog_report_spam_state(DialogId dialog_id, Promise<U
return false; return false;
} }
if (!have_input_peer(dialog_id, AccessRights::Read)) {
promise.set_error(Status::Error(3, "Can't access the chat"));
return false;
}
if (d->know_can_report_spam) { if (d->know_can_report_spam) {
promise.set_value(Unit()); promise.set_value(Unit());
return d->can_report_spam; return d->can_report_spam;
@ -22181,7 +22195,9 @@ void MessagesManager::on_dialog_is_blocked_updated(DialogId dialog_id, bool is_b
} }
} else { } else {
d->know_action_bar = false; d->know_action_bar = false;
// TODO repair_dialog_action_bar(d); if (have_input_peer(dialog_id, AccessRights::Read)) {
repair_dialog_action_bar(dialog_id);
}
// there is no need to change action bar // there is no need to change action bar
on_dialog_updated(dialog_id, "on_dialog_is_blocked_updated"); on_dialog_updated(dialog_id, "on_dialog_is_blocked_updated");
} }
@ -25784,6 +25800,16 @@ void MessagesManager::fix_new_dialog(Dialog *d, unique_ptr<Message> &&last_datab
// asynchronously get dialog folder id from the server // asynchronously get dialog folder id from the server
get_dialog_info_full(dialog_id, Auto()); get_dialog_info_full(dialog_id, Auto());
} }
if (!d->know_action_bar && !td_->auth_manager_->is_bot() && dialog_id != get_my_dialog_id() &&
have_input_peer(dialog_id, AccessRights::Read)) {
// asynchronously get action bar from the server
if (dialog_id.get_type() == DialogType::SecretChat) {
auto user_id = td_->contacts_manager_->get_secret_chat_user_id(dialog_id.get_secret_chat_id());
force_create_dialog(DialogId(user_id), "add chat with user to load/store action_bar");
} else {
repair_dialog_action_bar(dialog_id);
}
}
if (d->notification_settings.is_synchronized && !d->notification_settings.is_use_default_fixed && if (d->notification_settings.is_synchronized && !d->notification_settings.is_use_default_fixed &&
have_input_peer(dialog_id, AccessRights::Read) && !td_->auth_manager_->is_bot()) { have_input_peer(dialog_id, AccessRights::Read) && !td_->auth_manager_->is_bot()) {

View File

@ -1629,6 +1629,8 @@ class MessagesManager : public Actor {
void load_messages(DialogId dialog_id, MessageId from_message_id, int32 offset, int32 limit, int left_tries, void load_messages(DialogId dialog_id, MessageId from_message_id, int32 offset, int32 limit, int left_tries,
bool only_local, Promise<Unit> &&promise); bool only_local, Promise<Unit> &&promise);
void repair_dialog_action_bar(DialogId dialog_id);
static int32 get_random_y(MessageId message_id); static int32 get_random_y(MessageId message_id);
bool is_allowed_useless_update(const tl_object_ptr<telegram_api::Update> &update) const; bool is_allowed_useless_update(const tl_object_ptr<telegram_api::Update> &update) const;