Add messageProperties.can_be_reported.
This commit is contained in:
parent
e72f608122
commit
80467af525
@ -1506,7 +1506,7 @@ messageSendingStatePending sending_id:int32 = MessageSendingState;
|
|||||||
|
|
||||||
//@description The message failed to be sent
|
//@description The message failed to be sent
|
||||||
//@error The cause of the message sending failure
|
//@error The cause of the message sending failure
|
||||||
//@can_retry True, if the message can be re-sent
|
//@can_retry True, if the message can be re-sent using resendMessages or readdQuickReplyShortcutMessages
|
||||||
//@need_another_sender True, if the message can be re-sent only on behalf of a different sender
|
//@need_another_sender True, if the message can be re-sent only on behalf of a different sender
|
||||||
//@need_another_reply_quote True, if the message can be re-sent only if another quote is chosen in the message that is replied by the given message
|
//@need_another_reply_quote True, if the message can be re-sent only if another quote is chosen in the message that is replied by the given message
|
||||||
//@need_drop_reply True, if the message can be re-sent only if the message to be replied is removed. This will be done automatically by resendMessages
|
//@need_drop_reply True, if the message can be re-sent only if the message to be replied is removed. This will be done automatically by resendMessages
|
||||||
@ -3834,6 +3834,7 @@ inputMessageForwarded from_chat_id:int53 message_id:int53 in_game_share:Bool cop
|
|||||||
//-For live location and poll messages this fields shows whether editMessageLiveLocation or stopPoll can be used with this message
|
//-For live location and poll messages this fields shows whether editMessageLiveLocation or stopPoll can be used with this message
|
||||||
//@can_be_forwarded True, if the message can be forwarded using inputMessageForwarded or forwardMessages
|
//@can_be_forwarded True, if the message can be forwarded using inputMessageForwarded or forwardMessages
|
||||||
//@can_be_replied_in_another_chat True, if the message can be replied in another chat or topic using inputMessageReplyToExternalMessage
|
//@can_be_replied_in_another_chat True, if the message can be replied in another chat or topic using inputMessageReplyToExternalMessage
|
||||||
|
//@can_be_reported True, if the message can be reported using reportSupergroupSpam or reportChat
|
||||||
//@can_be_saved True, if content of the message can be saved locally or copied using inputMessageForwarded or forwardMessages with copy options
|
//@can_be_saved True, if content of the message can be saved locally or copied using inputMessageForwarded or forwardMessages with copy options
|
||||||
//@can_get_added_reactions True, if the list of added reactions is available using getMessageAddedReactions
|
//@can_get_added_reactions True, if the list of added reactions is available using getMessageAddedReactions
|
||||||
//@can_get_media_timestamp_links True, if media timestamp links can be generated for media timestamp entities in the message text, caption or link preview description using getMessageLink
|
//@can_get_media_timestamp_links True, if media timestamp links can be generated for media timestamp entities in the message text, caption or link preview description using getMessageLink
|
||||||
@ -3842,7 +3843,7 @@ inputMessageForwarded from_chat_id:int53 message_id:int53 in_game_share:Bool cop
|
|||||||
//@can_get_statistics True, if the message statistics are available through getMessageStatistics
|
//@can_get_statistics True, if the message statistics are available through getMessageStatistics
|
||||||
//@can_get_viewers True, if chat members already viewed the message can be received through getMessageViewers
|
//@can_get_viewers True, if chat members already viewed the message can be received through getMessageViewers
|
||||||
//@can_report_reactions True, if reactions on the message can be reported through reportMessageReactions
|
//@can_report_reactions True, if reactions on the message can be reported through reportMessageReactions
|
||||||
messageProperties can_be_deleted_only_for_self:Bool can_be_deleted_for_all_users:Bool can_be_edited:Bool can_be_forwarded:Bool can_be_replied_in_another_chat:Bool can_be_saved:Bool can_get_added_reactions:Bool can_get_media_timestamp_links:Bool can_get_message_thread:Bool can_get_read_date:Bool can_get_statistics:Bool can_get_viewers:Bool can_report_reactions:Bool = MessageProperties;
|
messageProperties can_be_deleted_only_for_self:Bool can_be_deleted_for_all_users:Bool can_be_edited:Bool can_be_forwarded:Bool can_be_replied_in_another_chat:Bool can_be_reported:Bool can_be_saved:Bool can_get_added_reactions:Bool can_get_media_timestamp_links:Bool can_get_message_thread:Bool can_get_read_date:Bool can_get_statistics:Bool can_get_viewers:Bool can_report_reactions:Bool = MessageProperties;
|
||||||
|
|
||||||
|
|
||||||
//@class SearchMessagesFilter @description Represents a filter for message search results
|
//@class SearchMessagesFilter @description Represents a filter for message search results
|
||||||
|
@ -3542,18 +3542,7 @@ void ChatManager::report_channel_spam(ChannelId channel_id, const vector<Message
|
|||||||
|
|
||||||
FlatHashMap<DialogId, vector<MessageId>, DialogIdHash> server_message_ids;
|
FlatHashMap<DialogId, vector<MessageId>, DialogIdHash> server_message_ids;
|
||||||
for (auto &message_id : message_ids) {
|
for (auto &message_id : message_ids) {
|
||||||
if (message_id.is_valid_scheduled()) {
|
TRY_STATUS_PROMISE(promise, MessagesManager::can_report_message(message_id));
|
||||||
return promise.set_error(Status::Error(400, "Can't report scheduled messages"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!message_id.is_valid()) {
|
|
||||||
return promise.set_error(Status::Error(400, "Message not found"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!message_id.is_server()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto sender_dialog_id = td_->messages_manager_->get_dialog_message_sender({DialogId(channel_id), message_id});
|
auto sender_dialog_id = td_->messages_manager_->get_dialog_message_sender({DialogId(channel_id), message_id});
|
||||||
CHECK(sender_dialog_id.get_type() != DialogType::SecretChat);
|
CHECK(sender_dialog_id.get_type() != DialogType::SecretChat);
|
||||||
if (sender_dialog_id.is_valid() && sender_dialog_id != td_->dialog_manager_->get_my_dialog_id() &&
|
if (sender_dialog_id.is_valid() && sender_dialog_id != td_->dialog_manager_->get_my_dialog_id() &&
|
||||||
|
@ -1807,21 +1807,15 @@ void DialogManager::report_dialog(DialogId dialog_id, const vector<MessageId> &m
|
|||||||
return promise.set_error(Status::Error(400, "Chat can't be reported"));
|
return promise.set_error(Status::Error(400, "Chat can't be reported"));
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<MessageId> server_message_ids;
|
|
||||||
for (auto message_id : message_ids) {
|
for (auto message_id : message_ids) {
|
||||||
if (message_id.is_scheduled()) {
|
TRY_STATUS_PROMISE(promise, MessagesManager::can_report_message(message_id));
|
||||||
return promise.set_error(Status::Error(400, "Can't report scheduled messages"));
|
|
||||||
}
|
|
||||||
if (message_id.is_valid() && message_id.is_server()) {
|
|
||||||
server_message_ids.push_back(message_id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dialog_id.get_type() == DialogType::Channel && reason.is_unrelated_location()) {
|
if (dialog_id.get_type() == DialogType::Channel && reason.is_unrelated_location()) {
|
||||||
td_->messages_manager_->hide_dialog_action_bar(dialog_id);
|
td_->messages_manager_->hide_dialog_action_bar(dialog_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
td_->create_handler<ReportPeerQuery>(std::move(promise))->send(dialog_id, server_message_ids, std::move(reason));
|
td_->create_handler<ReportPeerQuery>(std::move(promise))->send(dialog_id, message_ids, std::move(reason));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogManager::report_dialog_photo(DialogId dialog_id, FileId file_id, ReportReason &&reason,
|
void DialogManager::report_dialog_photo(DialogId dialog_id, FileId file_id, ReportReason &&reason,
|
||||||
|
@ -17301,7 +17301,7 @@ void MessagesManager::get_message_properties(DialogId dialog_id, MessageId messa
|
|||||||
if (m == nullptr) {
|
if (m == nullptr) {
|
||||||
if (message_id.is_valid_sponsored()) {
|
if (message_id.is_valid_sponsored()) {
|
||||||
return promise.set_value(td_api::make_object<td_api::messageProperties>(
|
return promise.set_value(td_api::make_object<td_api::messageProperties>(
|
||||||
false, false, false, false, false, false, false, false, false, false, false, false, false));
|
false, false, false, false, false, false, false, false, false, false, false, false, false, false));
|
||||||
}
|
}
|
||||||
return promise.set_error(Status::Error(400, "Message not found"));
|
return promise.set_error(Status::Error(400, "Message not found"));
|
||||||
}
|
}
|
||||||
@ -17337,6 +17337,7 @@ void MessagesManager::get_message_properties(DialogId dialog_id, MessageId messa
|
|||||||
auto can_be_edited = can_edit_message(dialog_id, m, false, is_bot);
|
auto can_be_edited = can_edit_message(dialog_id, m, false, is_bot);
|
||||||
auto can_be_forwarded = can_be_saved && can_forward_message(dialog_id, m);
|
auto can_be_forwarded = can_be_saved && can_forward_message(dialog_id, m);
|
||||||
auto can_be_replied_in_another_chat = can_be_forwarded && m->message_id.is_server();
|
auto can_be_replied_in_another_chat = can_be_forwarded && m->message_id.is_server();
|
||||||
|
auto can_be_reported = dialog_id.get_type() != DialogType::SecretChat && can_report_message(m->message_id).is_ok();
|
||||||
auto can_get_added_reactions = m->reactions != nullptr && m->reactions->can_get_added_reactions_;
|
auto can_get_added_reactions = m->reactions != nullptr && m->reactions->can_get_added_reactions_;
|
||||||
auto can_get_statistics = can_get_message_statistics(dialog_id, m);
|
auto can_get_statistics = can_get_message_statistics(dialog_id, m);
|
||||||
auto can_get_message_thread = get_top_thread_message_full_id(dialog_id, m, false).is_ok();
|
auto can_get_message_thread = get_top_thread_message_full_id(dialog_id, m, false).is_ok();
|
||||||
@ -17346,8 +17347,8 @@ void MessagesManager::get_message_properties(DialogId dialog_id, MessageId messa
|
|||||||
auto can_report_reactions = can_report_message_reactions(dialog_id, m);
|
auto can_report_reactions = can_report_message_reactions(dialog_id, m);
|
||||||
promise.set_value(td_api::make_object<td_api::messageProperties>(
|
promise.set_value(td_api::make_object<td_api::messageProperties>(
|
||||||
can_delete_for_self, can_delete_for_all_users, can_be_edited, can_be_forwarded, can_be_replied_in_another_chat,
|
can_delete_for_self, can_delete_for_all_users, can_be_edited, can_be_forwarded, can_be_replied_in_another_chat,
|
||||||
can_be_saved, can_get_added_reactions, can_get_media_timestamp_links, can_get_message_thread, can_get_read_date,
|
can_be_reported, can_be_saved, can_get_added_reactions, can_get_media_timestamp_links, can_get_message_thread,
|
||||||
can_get_statistics, can_get_viewers, can_report_reactions));
|
can_get_read_date, can_get_statistics, can_get_viewers, can_report_reactions));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MessagesManager::is_message_edited_recently(MessageFullId message_full_id, int32 seconds) {
|
bool MessagesManager::is_message_edited_recently(MessageFullId message_full_id, int32 seconds) {
|
||||||
@ -17422,6 +17423,22 @@ Status MessagesManager::can_get_media_timestamp_link(DialogId dialog_id, const M
|
|||||||
return Status::OK();
|
return Status::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Status MessagesManager::can_report_message(MessageId message_id) {
|
||||||
|
if (message_id.is_valid_scheduled()) {
|
||||||
|
return Status::Error(400, "Can't report scheduled messages");
|
||||||
|
}
|
||||||
|
if (message_id.is_valid_sponsored()) {
|
||||||
|
return Status::Error(400, "Can't report sponsored messages");
|
||||||
|
}
|
||||||
|
if (!message_id.is_valid()) {
|
||||||
|
return Status::Error(400, "Message not found");
|
||||||
|
}
|
||||||
|
if (!message_id.is_server()) {
|
||||||
|
return Status::Error(400, "Message can't be reported");
|
||||||
|
}
|
||||||
|
return Status::OK();
|
||||||
|
}
|
||||||
|
|
||||||
bool MessagesManager::can_report_message_reactions(DialogId dialog_id, const Message *m) const {
|
bool MessagesManager::can_report_message_reactions(DialogId dialog_id, const Message *m) const {
|
||||||
CHECK(m != nullptr);
|
CHECK(m != nullptr);
|
||||||
if (dialog_id.get_type() != DialogType::Channel || td_->dialog_manager_->is_broadcast_channel(dialog_id) ||
|
if (dialog_id.get_type() != DialogType::Channel || td_->dialog_manager_->is_broadcast_channel(dialog_id) ||
|
||||||
|
@ -560,6 +560,8 @@ class MessagesManager final : public Actor {
|
|||||||
vector<tl_object_ptr<telegram_api::peerBlocked>> &&blocked_peers,
|
vector<tl_object_ptr<telegram_api::peerBlocked>> &&blocked_peers,
|
||||||
Promise<td_api::object_ptr<td_api::messageSenders>> &&promise);
|
Promise<td_api::object_ptr<td_api::messageSenders>> &&promise);
|
||||||
|
|
||||||
|
static Status can_report_message(MessageId message_id);
|
||||||
|
|
||||||
bool can_get_message_statistics(MessageFullId message_full_id);
|
bool can_get_message_statistics(MessageFullId message_full_id);
|
||||||
|
|
||||||
DialogId get_dialog_message_sender(MessageFullId message_full_id);
|
DialogId get_dialog_message_sender(MessageFullId message_full_id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user