From 36ce823dcc1c869989cb5e0afe74f57e4f34ef0a Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 1 Nov 2023 18:32:55 +0300 Subject: [PATCH] Add separate flag message.can_be_replied_in_another_chat. --- td/generate/scheme/td_api.tl | 11 ++++++----- td/telegram/MessagesManager.cpp | 28 +++++++++++++++------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index c726cec43..5f229e7c5 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -1245,7 +1245,7 @@ messageReplyToStory story_sender_chat_id:int53 story_id:int32 = MessageReplyTo; //@class InputMessageReplyTo @description Contains information about the message or the story to be replied //@description Describes a message to be replied -//@chat_id The identifier of the chat to which the message to be replied belongs; pass 0 if the replied message is in the same chat. Must always be 0 for replies in secret chats. A message can be replied in another chat only if message.can_be_forwarded +//@chat_id The identifier of the chat to which the message to be replied belongs; pass 0 if the replied message is in the same chat. Must always be 0 for replies in secret chats. A message can be replied in another chat only if message.can_be_replied_in_another_chat //@message_id The identifier of the message to be replied in the same or the specified chat //@quote Manually chosen quote from the replied message; pass null if none; 0-getOption("message_reply_quote_length_max") characters. Must always be null for replies in secret chats. //-Only Bold, Italic, Underline, Strikethrough, Spoiler, and CustomEmoji entities are allowed to be kept and must be kept in the quote @@ -1264,7 +1264,8 @@ inputMessageReplyToStory story_sender_chat_id:int53 story_id:int32 = InputMessag //@is_outgoing True, if the message is outgoing //@is_pinned True, if the message is pinned //@can_be_edited True, if the message can be edited. For live location and poll messages this fields shows whether editMessageLiveLocation or stopPoll can be used with this message by the application -//@can_be_forwarded True, if the message can be forwarded or replied in another chat +//@can_be_forwarded True, if the message can be forwarded +//@can_be_replied_in_another_chat True, if the message can be replied in another chat //@can_be_saved True, if content of the message can be saved locally or copied //@can_be_deleted_only_for_self True, if the message can be deleted only for the current user while other users will continue to see it //@can_be_deleted_for_all_users True, if the message can be deleted for all users @@ -1295,7 +1296,7 @@ inputMessageReplyToStory story_sender_chat_id:int53 story_id:int32 = InputMessag //@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 if none -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 is_topic_message:Bool contains_unread_mention:Bool date:int32 edit_date:int32 forward_info:messageForwardInfo import_info:messageImportInfo interaction_info:messageInteractionInfo unread_reactions:vector reply_to:MessageReplyTo message_thread_id:int53 self_destruct_type:MessageSelfDestructType self_destruct_in:double auto_delete_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_replied_in_another_chat: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 is_topic_message:Bool contains_unread_mention:Bool date:int32 edit_date:int32 forward_info:messageForwardInfo import_info:messageImportInfo interaction_info:messageInteractionInfo unread_reactions:vector reply_to:MessageReplyTo message_thread_id:int53 self_destruct_type:MessageSelfDestructType self_destruct_in:double auto_delete_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 = Messages; @@ -3130,7 +3131,7 @@ inputMessageStory story_sender_chat_id:int53 story_id:int32 = InputMessageConten //@description A forwarded message //@from_chat_id Identifier for the chat this forwarded message came from -//@message_id Identifier of the message to forward +//@message_id Identifier of the message to forward. A message can be forwarded only if message.can_be_forwarded //@in_game_share True, if a game message is being shared from a launched game; applies only to game messages //@copy_options Options to be used to copy content of the message without reference to the original sender; pass null to forward the message as usual inputMessageForwarded from_chat_id:int53 message_id:int53 in_game_share:Bool copy_options:messageCopyOptions = InputMessageContent; @@ -7039,7 +7040,7 @@ sendInlineQueryResultMessage chat_id:int53 message_thread_id:int53 reply_to:Inpu //@chat_id Identifier of the chat to which to forward messages //@message_thread_id If not 0, a message thread identifier in which the message will be sent; for forum threads only //@from_chat_id Identifier of the chat from which to forward messages -//@message_ids Identifiers of the messages to forward. Message identifiers must be in a strictly increasing order. At most 100 messages can be forwarded simultaneously +//@message_ids Identifiers of the messages to forward. Message identifiers must be in a strictly increasing order. At most 100 messages can be forwarded simultaneously. A message can be forwarded only if message.can_be_forwarded //@options Options to be used to send the messages; pass null to use default options //@send_copy Pass true to copy content of the messages without reference to the original sender. Always true if the messages are forwarded to a secret chat or are local //@remove_caption Pass true to remove media captions of message copies. Ignored if send_copy is false diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 9acc25b39..4a53c75f6 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -24043,11 +24043,11 @@ td_api::object_ptr MessagesManager::get_dialog_event_log_messag get_message_own_max_media_timestamp(m), m->invert_media); return td_api::make_object( m->message_id.get(), std::move(sender), get_chat_id_object(dialog_id, "get_dialog_event_log_message_object"), - nullptr, nullptr, m->is_outgoing, false, false, false, can_be_saved, false, false, false, false, false, false, - false, false, true, m->is_channel_post, m->is_topic_message, false, m->date, edit_date, std::move(forward_info), - std::move(import_info), std::move(interaction_info), Auto(), nullptr, 0, nullptr, 0.0, 0.0, via_bot_user_id, - m->author_signature, 0, get_restriction_reason_description(m->restriction_reasons), std::move(content), - std::move(reply_markup)); + nullptr, nullptr, m->is_outgoing, false, false, false, false, can_be_saved, false, false, false, false, false, + false, false, false, true, m->is_channel_post, m->is_topic_message, false, m->date, edit_date, + std::move(forward_info), std::move(import_info), std::move(interaction_info), Auto(), nullptr, 0, nullptr, 0.0, + 0.0, via_bot_user_id, m->author_signature, 0, get_restriction_reason_description(m->restriction_reasons), + std::move(content), std::move(reply_markup)); } tl_object_ptr MessagesManager::get_message_object(MessageFullId message_full_id, const char *source) { @@ -24113,6 +24113,7 @@ tl_object_ptr MessagesManager::get_message_object(DialogId dial auto can_be_saved = can_save_message(dialog_id, m); auto can_be_edited = can_edit_message(dialog_id, m, false, td_->auth_manager_->is_bot()); 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_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_message_thread = get_top_thread_message_full_id(dialog_id, m, false).is_ok(); @@ -24155,13 +24156,14 @@ tl_object_ptr MessagesManager::get_message_object(DialogId dial return td_api::make_object( m->message_id.get(), std::move(sender), get_chat_id_object(dialog_id, "get_message_object"), std::move(sending_state), std::move(scheduling_state), is_outgoing, m->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, can_report_reactions, - has_timestamped_media, m->is_channel_post, m->is_topic_message, m->contains_unread_mention, date, edit_date, - std::move(forward_info), std::move(import_info), std::move(interaction_info), std::move(unread_reactions), - std::move(reply_to), top_thread_message_id, std::move(self_destruct_type), ttl_expires_in, auto_delete_in, - via_bot_user_id, m->author_signature, m->media_album_id, - get_restriction_reason_description(m->restriction_reasons), std::move(content), std::move(reply_markup)); + can_be_replied_in_another_chat, 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, can_report_reactions, has_timestamped_media, m->is_channel_post, + m->is_topic_message, m->contains_unread_mention, date, edit_date, std::move(forward_info), std::move(import_info), + std::move(interaction_info), std::move(unread_reactions), std::move(reply_to), top_thread_message_id, + std::move(self_destruct_type), ttl_expires_in, auto_delete_in, via_bot_user_id, m->author_signature, + m->media_album_id, get_restriction_reason_description(m->restriction_reasons), std::move(content), + std::move(reply_markup)); } tl_object_ptr MessagesManager::get_messages_object(int32 total_count, DialogId dialog_id, @@ -24563,7 +24565,7 @@ MessageInputReplyTo MessagesManager::get_message_input_reply_to( // TODO replies to yet unsent messages can be allowed with special handling of them on application restart return {}; } - if (reply_dialog_id != DialogId() && !can_forward_message(reply_dialog_id, m)) { + if (reply_dialog_id != DialogId() && (!can_forward_message(reply_dialog_id, m) || !m->message_id.is_server())) { LOG(INFO) << "Can't reply in another chat " << m->message_id << " in " << reply_d->dialog_id; return {}; }