Add message.can_report_reactions.

This commit is contained in:
levlam 2022-08-23 16:44:20 +03:00
parent 43f91a9de5
commit b359a09464
3 changed files with 29 additions and 6 deletions

View File

@ -884,6 +884,7 @@ messageSendingStateFailed error_code:int32 error_message:string can_retry:Bool n
//@can_get_message_thread True, if information about the message thread is available through getMessageThread and getMessageThreadHistory
//@can_get_viewers True, if chat members already viewed the message can be received through getMessageViewers
//@can_get_media_timestamp_links True, if media timestamp links can be generated for media timestamp entities in the message text, caption or web page description through getMessageLink
//@can_report_reactions True, if reactions on the message can be reported through reportMessageReactions
//@has_timestamped_media True, if media timestamp entities refers to a media in this message as opposed to a media in the replied message
//@is_channel_post True, if the message is a channel post. All messages to channels are channel posts, all other messages are not channel posts
//@contains_unread_mention True, if the message contains an unread mention for the current user
@ -903,7 +904,7 @@ messageSendingStateFailed error_code:int32 error_message:string can_retry:Bool n
//@restriction_reason If non-empty, contains a human-readable description of the reason why access to this message must be restricted
//@content Content of the message
//@reply_markup Reply markup for the message; may be null
message id:int53 sender_id:MessageSender chat_id:int53 sending_state:MessageSendingState scheduling_state:MessageSchedulingState is_outgoing:Bool is_pinned:Bool can_be_edited:Bool can_be_forwarded:Bool can_be_saved:Bool can_be_deleted_only_for_self:Bool can_be_deleted_for_all_users:Bool can_get_added_reactions:Bool can_get_statistics:Bool can_get_message_thread:Bool can_get_viewers:Bool can_get_media_timestamp_links:Bool has_timestamped_media:Bool is_channel_post:Bool contains_unread_mention:Bool date:int32 edit_date:int32 forward_info:messageForwardInfo interaction_info:messageInteractionInfo unread_reactions:vector<unreadReaction> reply_in_chat_id:int53 reply_to_message_id:int53 message_thread_id:int53 ttl:int32 ttl_expires_in:double via_bot_user_id:int53 author_signature:string media_album_id:int64 restriction_reason:string content:MessageContent reply_markup:ReplyMarkup = Message;
message id:int53 sender_id:MessageSender chat_id:int53 sending_state:MessageSendingState scheduling_state:MessageSchedulingState is_outgoing:Bool is_pinned:Bool can_be_edited:Bool can_be_forwarded:Bool can_be_saved:Bool can_be_deleted_only_for_self:Bool can_be_deleted_for_all_users:Bool can_get_added_reactions:Bool can_get_statistics:Bool can_get_message_thread:Bool can_get_viewers:Bool can_get_media_timestamp_links:Bool can_report_reactions:Bool has_timestamped_media:Bool is_channel_post:Bool contains_unread_mention:Bool date:int32 edit_date:int32 forward_info:messageForwardInfo interaction_info:messageInteractionInfo unread_reactions:vector<unreadReaction> reply_in_chat_id:int53 reply_to_message_id:int53 message_thread_id:int53 ttl:int32 ttl_expires_in:double via_bot_user_id:int53 author_signature:string media_album_id:int64 restriction_reason:string content:MessageContent reply_markup:ReplyMarkup = Message;
//@description Contains a list of messages @total_count Approximate total number of messages found @messages List of messages; messages may be null
messages total_count:int32 messages:vector<message> = Messages;

View File

@ -18723,6 +18723,25 @@ Status MessagesManager::can_get_media_timestamp_link(DialogId dialog_id, const M
return Status::OK();
}
bool MessagesManager::can_report_message_reactions(DialogId dialog_id, const Message *m) const {
CHECK(m != nullptr);
if (dialog_id.get_type() != DialogType::Channel || is_broadcast_channel(dialog_id) ||
!td_->contacts_manager_->is_channel_public(dialog_id.get_channel_id())) {
return false;
}
if (m->message_id.is_scheduled() || !m->message_id.is_server()) {
return false;
}
if (m->message_id.is_scheduled() || !m->message_id.is_server()) {
return false;
}
if (is_discussion_message(dialog_id, m)) {
return false;
}
return true;
}
Result<std::pair<string, bool>> MessagesManager::get_message_link(FullMessageId full_message_id, int32 media_timestamp,
bool for_group, bool for_comment) {
auto dialog_id = full_message_id.get_dialog_id();
@ -24719,6 +24738,7 @@ tl_object_ptr<td_api::message> MessagesManager::get_message_object(DialogId dial
auto can_get_message_thread = for_event_log ? false : get_top_thread_full_message_id(dialog_id, m).is_ok();
auto can_get_viewers = for_event_log ? false : can_get_message_viewers(dialog_id, m).is_ok();
auto can_get_media_timestamp_links = for_event_log ? false : can_get_media_timestamp_link(dialog_id, m).is_ok();
auto can_report_reactions = for_event_log ? false : can_report_message_reactions(dialog_id, m);
auto via_bot_user_id = td_->contacts_manager_->get_user_id_object(m->via_bot_user_id, "via_bot_user_id");
auto media_album_id = for_event_log ? static_cast<int64>(0) : m->media_album_id;
auto reply_to_message_id = for_event_log ? static_cast<int64>(0) : m->reply_to_message_id.get();
@ -24742,11 +24762,11 @@ tl_object_ptr<td_api::message> MessagesManager::get_message_object(DialogId dial
m->message_id.get(), std::move(sender), dialog_id.get(), std::move(sending_state), std::move(scheduling_state),
is_outgoing, is_pinned, can_be_edited, can_be_forwarded, can_be_saved, can_delete_for_self,
can_delete_for_all_users, can_get_added_reactions, can_get_statistics, can_get_message_thread, can_get_viewers,
can_get_media_timestamp_links, has_timestamped_media, m->is_channel_post, contains_unread_mention, date,
edit_date, std::move(forward_info), std::move(interaction_info), std::move(unread_reactions),
reply_in_dialog_id.get(), reply_to_message_id, top_thread_message_id, ttl, ttl_expires_in, via_bot_user_id,
m->author_signature, media_album_id, get_restriction_reason_description(m->restriction_reasons),
std::move(content), std::move(reply_markup));
can_get_media_timestamp_links, can_report_reactions, has_timestamped_media, m->is_channel_post,
contains_unread_mention, date, edit_date, std::move(forward_info), std::move(interaction_info),
std::move(unread_reactions), reply_in_dialog_id.get(), reply_to_message_id, top_thread_message_id, ttl,
ttl_expires_in, via_bot_user_id, m->author_signature, media_album_id,
get_restriction_reason_description(m->restriction_reasons), std::move(content), std::move(reply_markup));
}
tl_object_ptr<td_api::messages> MessagesManager::get_messages_object(int32 total_count, DialogId dialog_id,

View File

@ -1903,6 +1903,8 @@ class MessagesManager final : public Actor {
static Status can_get_media_timestamp_link(DialogId dialog_id, const Message *m);
bool can_report_message_reactions(DialogId dialog_id, const Message *m) const;
Status can_get_message_viewers(FullMessageId full_message_id) TD_WARN_UNUSED_RESULT;
Status can_get_message_viewers(DialogId dialog_id, const Message *m) const TD_WARN_UNUSED_RESULT;