diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index a3bc1b6d3..ad9f9e62c 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -6440,6 +6440,9 @@ toggleSupergroupIsBroadcastGroup supergroup_id:int53 = Ok; //@description Reports messages in a supergroup as spam; requires administrator rights in the supergroup @supergroup_id Supergroup identifier @message_ids Identifiers of messages to report reportSupergroupSpam supergroup_id:int53 message_ids:vector = Ok; +//@description Reports a false deletion of a message by aggressive anti-spam checks; requires administrator rights in the supergroup. Can be called only for messages from chatEventMessageDeleted with can_report_anti_spam_false_positive == true @supergroup_id Supergroup identifier @message_id Identifier of the erroneously deleted message +reportSupergroupAntiSpamFalsePositive supergroup_id:int53 message_id:int53 = Ok; + //@description Returns information about members or banned users in a supergroup or channel. Can be used only if supergroupFullInfo.can_get_members == true; additionally, administrator privileges may be required for some filters @supergroup_id Identifier of the supergroup or channel //@filter The type of users to return; pass null to use supergroupMembersFilterRecent @offset Number of users to skip @limit The maximum number of users be returned; up to 200 getSupergroupMembers supergroup_id:int53 filter:SupergroupMembersFilter offset:int32 limit:int32 = ChatMembers; diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 3ba695288..f672aeb05 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -1586,6 +1586,42 @@ class ReportChannelSpamQuery final : public Td::ResultHandler { } }; +class ReportChannelAntiSpamFalsePositiveQuery final : public Td::ResultHandler { + Promise promise_; + ChannelId channel_id_; + + public: + explicit ReportChannelAntiSpamFalsePositiveQuery(Promise &&promise) : promise_(std::move(promise)) { + } + + void send(ChannelId channel_id, MessageId message_id) { + channel_id_ = channel_id; + + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id); + CHECK(input_channel != nullptr); + + send_query(G()->net_query_creator().create(telegram_api::channels_reportAntiSpamFalsePositive( + std::move(input_channel), message_id.get_server_message_id().get()))); + } + + void on_result(BufferSlice packet) final { + auto result_ptr = fetch_result(packet); + if (result_ptr.is_error()) { + return on_error(result_ptr.move_as_error()); + } + + bool result = result_ptr.move_as_ok(); + LOG_IF(INFO, !result) << "Report anti-spam false positive has failed in " << channel_id_; + + promise_.set_value(Unit()); + } + + void on_error(Status status) final { + td_->contacts_manager_->on_get_channel_error(channel_id_, status, "ReportChannelAntiSpamFalsePositiveQuery"); + promise_.set_error(std::move(status)); + } +}; + class DeleteChatQuery final : public Td::ResultHandler { Promise promise_; @@ -7695,6 +7731,27 @@ void ContactsManager::report_channel_spam(ChannelId channel_id, const vector &&promise) { + auto c = get_channel(channel_id); + if (c == nullptr) { + return promise.set_error(Status::Error(400, "Supergroup not found")); + } + if (!c->is_megagroup) { + return promise.set_error(Status::Error(400, "The chat is not a supergroup")); + } + if (!c->status.is_administrator()) { + return promise.set_error( + Status::Error(400, "Anti-spam checks false positives can be reported only by chat administrators")); + } + + if (!message_id.is_valid() || !message_id.is_server()) { + return promise.set_error(Status::Error(400, "Invalid message identifier specified")); + } + + td_->create_handler(std::move(promise))->send(channel_id, message_id); +} + void ContactsManager::delete_chat(ChatId chat_id, Promise &&promise) { auto c = get_chat(chat_id); if (c == nullptr) { diff --git a/td/telegram/ContactsManager.h b/td/telegram/ContactsManager.h index 0d14e85fb..b95706629 100644 --- a/td/telegram/ContactsManager.h +++ b/td/telegram/ContactsManager.h @@ -414,6 +414,8 @@ class ContactsManager final : public Actor { void report_channel_spam(ChannelId channel_id, const vector &message_ids, Promise &&promise); + void report_channel_anti_spam_false_positive(ChannelId channel_id, MessageId message_id, Promise &&promise); + void delete_dialog(DialogId dialog_id, Promise &&promise); void get_channel_statistics_dc_id(DialogId dialog_id, bool for_full_statistics, Promise &&promise); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 2fd5b8a46..6372a1390 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -6989,6 +6989,13 @@ void Td::on_request(uint64 id, const td_api::reportSupergroupSpam &request) { MessagesManager::get_message_ids(request.message_ids_), std::move(promise)); } +void Td::on_request(uint64 id, const td_api::reportSupergroupAntiSpamFalsePositive &request) { + CHECK_IS_USER(); + CREATE_OK_REQUEST_PROMISE(); + contacts_manager_->report_channel_anti_spam_false_positive(ChannelId(request.supergroup_id_), + MessageId(request.message_id_), std::move(promise)); +} + void Td::on_request(uint64 id, td_api::getSupergroupMembers &request) { CREATE_REQUEST_PROMISE(); auto query_promise = diff --git a/td/telegram/Td.h b/td/telegram/Td.h index 9342a744d..0c7075db1 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -1110,6 +1110,8 @@ class Td final : public Actor { void on_request(uint64 id, const td_api::reportSupergroupSpam &request); + void on_request(uint64 id, const td_api::reportSupergroupAntiSpamFalsePositive &request); + void on_request(uint64 id, td_api::getSupergroupMembers &request); void on_request(uint64 id, td_api::closeSecretChat &request); diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index dcdb41747..f4ba6b870 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -4966,6 +4966,12 @@ class CliClient final : public Actor { get_args(args, supergroup_id, message_ids); send_request(td_api::make_object(as_supergroup_id(supergroup_id), as_message_ids(message_ids))); + } else if (op == "rsgasfp") { + string supergroup_id; + MessageId message_id; + get_args(args, supergroup_id, message_id); + send_request(td_api::make_object(as_supergroup_id(supergroup_id), + message_id)); } else if (op == "gdiff") { send_request(td_api::make_object()); } else if (op == "dproxy") {