diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 41827f75..bf291095 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -628,7 +628,7 @@ chatListArchive = ChatList; //@last_read_outbox_message_id Identifier of the last read outgoing message //@unread_mention_count Number of unread messages with a mention/reply in the chat //@notification_settings Notification settings for this chat -//@action_bar Describes actions which should be possible to do through a chat action bar +//@action_bar Describes actions which should be possible to do through a chat action bar; may be null //@pinned_message_id Identifier of the pinned message in the chat; 0 if none //@reply_markup_message_id Identifier of the message from which reply markup needs to be used; 0 if there is no default custom reply markup in the chat //@draft_message A draft of a message in the chat; may be null diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 34b6d51b..8f6693ae 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -7248,6 +7248,11 @@ void ContactsManager::update_user_full(UserFull *user_full, UserId user_id, bool td_->messages_manager_->drop_common_dialogs_cache(user_id); user_full->is_common_chat_count_changed = false; } + if (user_full->is_is_blocked_changed) { + td_->messages_manager_->on_dialog_is_blocked_updated(DialogId(user_id), user_full->is_blocked); + user_full->is_is_blocked_changed = false; + } + if (user_full->is_changed) { user_full->is_changed = false; if (user_full->is_inited) { @@ -8028,6 +8033,9 @@ void ContactsManager::on_update_user_blocked(UserId user_id, bool is_blocked) { } UserFull *user_full = get_user_full_force(user_id); + if (user_full == nullptr || !user_full->is_inited) { + td_->messages_manager_->on_dialog_is_blocked_updated(DialogId(user_id), is_blocked); + } if (user_full == nullptr) { return; } @@ -8038,6 +8046,7 @@ void ContactsManager::on_update_user_blocked(UserId user_id, bool is_blocked) { void ContactsManager::on_update_user_full_is_blocked(UserFull *user_full, UserId user_id, bool is_blocked) { CHECK(user_full != nullptr); if (user_full->is_inited && user_full->is_blocked != is_blocked) { + user_full->is_is_blocked_changed = true; user_full->is_blocked = is_blocked; user_full->is_changed = true; } diff --git a/td/telegram/ContactsManager.h b/td/telegram/ContactsManager.h index 8a2e5b66..67c5a082 100644 --- a/td/telegram/ContactsManager.h +++ b/td/telegram/ContactsManager.h @@ -580,6 +580,7 @@ class ContactsManager : public Actor { bool can_pin_messages = false; bool need_phone_number_privacy_exception = false; + bool is_is_blocked_changed = true; bool is_common_chat_count_changed = true; bool is_changed = true; diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index f7c8a5bd..3b646b56 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -22158,6 +22158,29 @@ void MessagesManager::on_dialog_permissions_updated(DialogId dialog_id) { } } +void MessagesManager::on_dialog_is_blocked_updated(DialogId dialog_id, bool is_blocked) { + CHECK(dialog_id.get_type() == DialogType::User); + auto d = get_dialog(dialog_id); // called from update_user_full, must not create the dialog + if (d != nullptr && d->is_update_new_chat_sent) { + if (d->know_action_bar) { + if (is_blocked) { + if (d->can_report_spam || d->can_share_phone_number || d->can_block_user || d->can_add_contact) { + d->can_report_spam = false; + d->can_share_phone_number = false; + d->can_block_user = false; + d->can_add_contact = false; + // TODO send_update_chat_action_bar(d); + on_dialog_updated(dialog_id, "on_dialog_is_blocked_updated 1"); + } + } else { + d->know_action_bar = false; + // TODO repair_dialog_action_bar(d); + on_dialog_updated(dialog_id, "on_dialog_is_blocked_updated 2"); + } + } + } +} + DialogId MessagesManager::resolve_dialog_username(const string &username) const { auto cleaned_username = clean_username(username); auto it = resolved_usernames_.find(cleaned_username); diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index b926e655..f9c9e578 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -642,6 +642,7 @@ class MessagesManager : public Actor { void on_dialog_title_updated(DialogId dialog_id); void on_dialog_username_updated(DialogId dialog_id, const string &old_username, const string &new_username); void on_dialog_permissions_updated(DialogId dialog_id); + void on_dialog_is_blocked_updated(DialogId dialog_id, bool is_blocked); void on_resolved_username(const string &username, DialogId dialog_id); void drop_username(const string &username);