Add td_api::reportSupergroupAntiSpamFalsePositive.

This commit is contained in:
levlam 2022-11-25 16:38:00 +03:00
parent 6827c79570
commit 3d3f73df7a
6 changed files with 77 additions and 0 deletions

View File

@ -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<int53> = 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;

View File

@ -1586,6 +1586,42 @@ class ReportChannelSpamQuery final : public Td::ResultHandler {
}
};
class ReportChannelAntiSpamFalsePositiveQuery final : public Td::ResultHandler {
Promise<Unit> promise_;
ChannelId channel_id_;
public:
explicit ReportChannelAntiSpamFalsePositiveQuery(Promise<Unit> &&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<telegram_api::channels_reportAntiSpamFalsePositive>(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<Unit> promise_;
@ -7695,6 +7731,27 @@ void ContactsManager::report_channel_spam(ChannelId channel_id, const vector<Mes
lock_promise.set_value(Unit());
}
void ContactsManager::report_channel_anti_spam_false_positive(ChannelId channel_id, MessageId message_id,
Promise<Unit> &&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<ReportChannelAntiSpamFalsePositiveQuery>(std::move(promise))->send(channel_id, message_id);
}
void ContactsManager::delete_chat(ChatId chat_id, Promise<Unit> &&promise) {
auto c = get_chat(chat_id);
if (c == nullptr) {

View File

@ -414,6 +414,8 @@ class ContactsManager final : public Actor {
void report_channel_spam(ChannelId channel_id, const vector<MessageId> &message_ids, Promise<Unit> &&promise);
void report_channel_anti_spam_false_positive(ChannelId channel_id, MessageId message_id, Promise<Unit> &&promise);
void delete_dialog(DialogId dialog_id, Promise<Unit> &&promise);
void get_channel_statistics_dc_id(DialogId dialog_id, bool for_full_statistics, Promise<DcId> &&promise);

View File

@ -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 =

View File

@ -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);

View File

@ -4966,6 +4966,12 @@ class CliClient final : public Actor {
get_args(args, supergroup_id, message_ids);
send_request(td_api::make_object<td_api::reportSupergroupSpam>(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<td_api::reportSupergroupAntiSpamFalsePositive>(as_supergroup_id(supergroup_id),
message_id));
} else if (op == "gdiff") {
send_request(td_api::make_object<td_api::testGetDifference>());
} else if (op == "dproxy") {