Add td_api::reportMessageReactions.
This commit is contained in:
parent
d1cc119b9d
commit
43f91a9de5
@ -6323,6 +6323,11 @@ reportChat chat_id:int53 message_ids:vector<int53> reason:ChatReportReason text:
|
|||||||
//@chat_id Chat identifier @file_id Identifier of the photo to report. Only full photos from chatPhoto can be reported @reason The reason for reporting the chat photo @text Additional report details; 0-1024 characters
|
//@chat_id Chat identifier @file_id Identifier of the photo to report. Only full photos from chatPhoto can be reported @reason The reason for reporting the chat photo @text Additional report details; 0-1024 characters
|
||||||
reportChatPhoto chat_id:int53 file_id:int32 reason:ChatReportReason text:string = Ok;
|
reportChatPhoto chat_id:int53 file_id:int32 reason:ChatReportReason text:string = Ok;
|
||||||
|
|
||||||
|
//@description Reports reactions set on a message to the Telegram moderators. Reactions on a message can be reported only if message.can_report_reactions
|
||||||
|
//@chat_id Chat identifier @message_id Message identifier @sender_id Identifier of the sender, added the reaction
|
||||||
|
reportMessageReactions chat_id:int53 message_id:int53 sender_id:MessageSender = Ok;
|
||||||
|
|
||||||
|
|
||||||
//@description Returns detailed statistics about a chat. Currently, this method can be used only for supergroups and channels. Can be used only if supergroupFullInfo.can_get_statistics == true @chat_id Chat identifier @is_dark Pass true if a dark theme is used by the application
|
//@description Returns detailed statistics about a chat. Currently, this method can be used only for supergroups and channels. Can be used only if supergroupFullInfo.can_get_statistics == true @chat_id Chat identifier @is_dark Pass true if a dark theme is used by the application
|
||||||
getChatStatistics chat_id:int53 is_dark:Bool = ChatStatistics;
|
getChatStatistics chat_id:int53 is_dark:Bool = ChatStatistics;
|
||||||
|
|
||||||
|
@ -349,6 +349,44 @@ class SetDefaultReactionQuery final : public Td::ResultHandler {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ReportReactionQuery final : public Td::ResultHandler {
|
||||||
|
Promise<Unit> promise_;
|
||||||
|
DialogId dialog_id_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ReportReactionQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void send(DialogId dialog_id, MessageId message_id, DialogId chooser_dialog_id) {
|
||||||
|
dialog_id_ = dialog_id;
|
||||||
|
|
||||||
|
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
|
||||||
|
CHECK(input_peer != nullptr);
|
||||||
|
|
||||||
|
auto chooser_input_peer = td_->messages_manager_->get_input_peer(chooser_dialog_id, AccessRights::Know);
|
||||||
|
if (chooser_input_peer == nullptr) {
|
||||||
|
return promise_.set_error(Status::Error(400, "Reaction sender is not accessible"));
|
||||||
|
}
|
||||||
|
|
||||||
|
send_query(G()->net_query_creator().create(telegram_api::messages_reportReaction(
|
||||||
|
std::move(input_peer), message_id.get_server_message_id().get(), std::move(chooser_input_peer))));
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_result(BufferSlice packet) final {
|
||||||
|
auto result_ptr = fetch_result<telegram_api::messages_reportReaction>(packet);
|
||||||
|
if (result_ptr.is_error()) {
|
||||||
|
return on_error(result_ptr.move_as_error());
|
||||||
|
}
|
||||||
|
|
||||||
|
promise_.set_value(Unit());
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_error(Status status) final {
|
||||||
|
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "ReportReactionQuery");
|
||||||
|
promise_.set_error(std::move(status));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
void MessageReaction::add_recent_chooser_dialog_id(DialogId dialog_id) {
|
void MessageReaction::add_recent_chooser_dialog_id(DialogId dialog_id) {
|
||||||
recent_chooser_dialog_ids_.insert(recent_chooser_dialog_ids_.begin(), dialog_id);
|
recent_chooser_dialog_ids_.insert(recent_chooser_dialog_ids_.begin(), dialog_id);
|
||||||
if (recent_chooser_dialog_ids_.size() > MAX_RECENT_CHOOSERS + 1) {
|
if (recent_chooser_dialog_ids_.size() > MAX_RECENT_CHOOSERS + 1) {
|
||||||
@ -710,4 +748,32 @@ void send_update_default_reaction_type(const string &default_reaction) {
|
|||||||
td_api::make_object<td_api::updateDefaultReactionType>(get_reaction_type_object(default_reaction)));
|
td_api::make_object<td_api::updateDefaultReactionType>(get_reaction_type_object(default_reaction)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void report_message_reactions(Td *td, FullMessageId full_message_id, DialogId chooser_dialog_id,
|
||||||
|
Promise<Unit> &&promise) {
|
||||||
|
auto dialog_id = full_message_id.get_dialog_id();
|
||||||
|
if (!td->messages_manager_->have_dialog_force(dialog_id, "send_callback_query")) {
|
||||||
|
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||||
|
}
|
||||||
|
if (!td->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
|
||||||
|
return promise.set_error(Status::Error(400, "Can't access the chat"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!td->messages_manager_->have_message_force(full_message_id, "report_user_reactions")) {
|
||||||
|
return promise.set_error(Status::Error(400, "Message not found"));
|
||||||
|
}
|
||||||
|
auto message_id = full_message_id.get_message_id();
|
||||||
|
if (message_id.is_valid_scheduled()) {
|
||||||
|
return promise.set_error(Status::Error(400, "Can't report reactions on scheduled messages"));
|
||||||
|
}
|
||||||
|
if (!message_id.is_server()) {
|
||||||
|
return promise.set_error(Status::Error(400, "Message reactions can't be reported"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!td->messages_manager_->have_input_peer(chooser_dialog_id, AccessRights::Know)) {
|
||||||
|
return promise.set_error(Status::Error(400, "Reaction sender not found"));
|
||||||
|
}
|
||||||
|
|
||||||
|
td->create_handler<ReportReactionQuery>(std::move(promise))->send(dialog_id, message_id, chooser_dialog_id);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -190,4 +190,7 @@ void send_set_default_reaction_query(Td *td);
|
|||||||
|
|
||||||
void send_update_default_reaction_type(const string &default_reaction);
|
void send_update_default_reaction_type(const string &default_reaction);
|
||||||
|
|
||||||
|
void report_message_reactions(Td *td, FullMessageId full_message_id, DialogId chooser_dialog_id,
|
||||||
|
Promise<Unit> &&promise);
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -7180,6 +7180,14 @@ void Td::on_request(uint64 id, td_api::reportChatPhoto &request) {
|
|||||||
r_report_reason.move_as_ok(), std::move(promise));
|
r_report_reason.move_as_ok(), std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Td::on_request(uint64 id, const td_api::reportMessageReactions &request) {
|
||||||
|
CHECK_IS_USER();
|
||||||
|
CREATE_OK_REQUEST_PROMISE();
|
||||||
|
TRY_RESULT_PROMISE(promise, sender_dialog_id, get_message_sender_dialog_id(this, request.sender_id_, false, false));
|
||||||
|
report_message_reactions(this, {DialogId(request.chat_id_), MessageId(request.message_id_)}, sender_dialog_id,
|
||||||
|
std::move(promise));
|
||||||
|
}
|
||||||
|
|
||||||
void Td::on_request(uint64 id, const td_api::getChatStatistics &request) {
|
void Td::on_request(uint64 id, const td_api::getChatStatistics &request) {
|
||||||
CHECK_IS_USER();
|
CHECK_IS_USER();
|
||||||
CREATE_REQUEST_PROMISE();
|
CREATE_REQUEST_PROMISE();
|
||||||
|
@ -1154,6 +1154,8 @@ class Td final : public Actor {
|
|||||||
|
|
||||||
void on_request(uint64 id, td_api::reportChatPhoto &request);
|
void on_request(uint64 id, td_api::reportChatPhoto &request);
|
||||||
|
|
||||||
|
void on_request(uint64 id, const td_api::reportMessageReactions &request);
|
||||||
|
|
||||||
void on_request(uint64 id, const td_api::getChatStatistics &request);
|
void on_request(uint64 id, const td_api::getChatStatistics &request);
|
||||||
|
|
||||||
void on_request(uint64 id, const td_api::getMessageStatistics &request);
|
void on_request(uint64 id, const td_api::getMessageStatistics &request);
|
||||||
|
@ -4748,6 +4748,13 @@ class CliClient final : public Actor {
|
|||||||
get_args(args, chat_id, file_id, reason, text);
|
get_args(args, chat_id, file_id, reason, text);
|
||||||
send_request(
|
send_request(
|
||||||
td_api::make_object<td_api::reportChatPhoto>(chat_id, file_id, get_chat_report_reason(reason), text));
|
td_api::make_object<td_api::reportChatPhoto>(chat_id, file_id, get_chat_report_reason(reason), text));
|
||||||
|
} else if (op == "rmr") {
|
||||||
|
ChatId chat_id;
|
||||||
|
MessageId message_id;
|
||||||
|
string sender_id;
|
||||||
|
get_args(args, chat_id, message_id, sender_id);
|
||||||
|
send_request(
|
||||||
|
td_api::make_object<td_api::reportMessageReactions>(chat_id, message_id, as_message_sender(sender_id)));
|
||||||
} else if (op == "gcst") {
|
} else if (op == "gcst") {
|
||||||
ChatId chat_id;
|
ChatId chat_id;
|
||||||
bool is_dark;
|
bool is_dark;
|
||||||
|
Loading…
Reference in New Issue
Block a user