diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index b952a7b9..707f680f 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -3907,6 +3907,9 @@ getChatReportSpamState chat_id:int53 = ChatReportSpamState; //@description Reports to the server whether a chat is a spam chat or not. Can be used only if ChatReportSpamState.can_report_spam is true. After this request, ChatReportSpamState.can_report_spam becomes false forever @chat_id Chat identifier @is_spam_chat If true, the chat will be reported as spam; otherwise it will be marked as not spam changeChatReportSpamState chat_id:int53 is_spam_chat:Bool = Ok; +//@description Removes a chat action bar without any other action @chat_id Chat identifier +removeChatActionBar chat_id:int53 = Ok; + //@description Reports a chat to the Telegram moderators. Supported only for supergroups, channels, or private chats with bots, since other chats can't be checked by moderators @chat_id Chat identifier @reason The reason for reporting the chat @message_ids Identifiers of reported messages, if any reportChat chat_id:int53 reason:ChatReportReason message_ids:vector = Ok; diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index d2bb1dd6..de23e5c2 100644 Binary files a/td/generate/scheme/td_api.tlo and b/td/generate/scheme/td_api.tlo differ diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 78e159a5..e951dd7e 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -3223,7 +3223,9 @@ class UpdatePeerSettingsQuery : public Td::ResultHandler { dialog_id_ = dialog_id; auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); - CHECK(input_peer != nullptr); + if (input_peer == nullptr) { + return promise_.set_value(Unit()); + } if (is_spam_dialog) { send_query( @@ -6508,6 +6510,35 @@ void MessagesManager::change_dialog_report_spam_state(DialogId dialog_id, bool i change_dialog_report_spam_state_on_server(dialog_id, is_spam_dialog, 0, std::move(promise)); } +void MessagesManager::remove_dialog_action_bar(DialogId dialog_id, Promise &&promise) { + Dialog *d = get_dialog_force(dialog_id); + if (d == nullptr) { + return promise.set_error(Status::Error(3, "Chat not found")); + } + + if (!have_input_peer(dialog_id, AccessRights::Read)) { + return promise.set_error(Status::Error(3, "Can't access the chat")); + } + + if (!d->know_can_report_spam) { + return promise.set_error(Status::Error(3, "Can't update chat action bar")); + } + + if (!d->can_report_spam && !d->can_add_contact && !d->can_block_user && !d->can_share_phone_number && + !d->can_report_location) { + return promise.set_value(Unit()); + } + + d->can_report_spam = false; + d->can_add_contact = false; + d->can_block_user = false; + d->can_share_phone_number = false; + d->can_report_location = false; + on_dialog_updated(dialog_id, "remove_dialog_action_bar"); + + change_dialog_report_spam_state_on_server(dialog_id, false, 0, std::move(promise)); +} + class MessagesManager::ChangeDialogReportSpamStateOnServerLogEvent { public: DialogId dialog_id_; @@ -6551,8 +6582,8 @@ void MessagesManager::change_dialog_report_spam_state_on_server(DialogId dialog_ if (is_spam_dialog) { return td_->create_handler(std::move(promise))->send(dialog_id); } else { - promise.set_value(Unit()); - return; + auto user_id = td_->contacts_manager_->get_secret_chat_user_id(dialog_id.get_secret_chat_id()); + return td_->create_handler(std::move(promise))->send(DialogId(user_id), false); } case DialogType::None: default: diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index b0afe9a3..355441dc 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -667,6 +667,8 @@ class MessagesManager : public Actor { void change_dialog_report_spam_state(DialogId dialog_id, bool is_spam_dialog, Promise &&promise); + void remove_dialog_action_bar(DialogId dialog_id, Promise &&promise); + void report_dialog(DialogId dialog_id, const tl_object_ptr &reason, const vector &message_ids, Promise &&promise); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index d6fbc837..db99e7e3 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -6688,6 +6688,12 @@ void Td::on_request(uint64 id, const td_api::changeChatReportSpamState &request) std::move(promise)); } +void Td::on_request(uint64 id, const td_api::removeChatActionBar &request) { + CHECK_IS_USER(); + CREATE_OK_REQUEST_PROMISE(); + messages_manager_->remove_dialog_action_bar(DialogId(request.chat_id_), std::move(promise)); +} + void Td::on_request(uint64 id, td_api::reportChat &request) { CHECK_IS_USER(); CREATE_OK_REQUEST_PROMISE(); diff --git a/td/telegram/Td.h b/td/telegram/Td.h index b57362b7..9b82aeeb 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -848,6 +848,8 @@ class Td final : public NetQueryCallback { void on_request(uint64 id, const td_api::changeChatReportSpamState &request); + void on_request(uint64 id, const td_api::removeChatActionBar &request); + void on_request(uint64 id, td_api::reportChat &request); void on_request(uint64 id, td_api::getChatStatisticsUrl &request); diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index de306124..3e52b76b 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -3626,6 +3626,9 @@ class CliClient final : public Actor { std::tie(chat_id, is_spam_chat) = split(args); send_request(td_api::make_object(as_chat_id(chat_id), as_bool(is_spam_chat))); + } else if (op == "rcab") { + string chat_id = args; + send_request(td_api::make_object(as_chat_id(chat_id))); } else if (op == "rc") { string chat_id; string reason_str;