From 7f5da4b5c5f1bdd5f1572f32102f99e0e4b2113f Mon Sep 17 00:00:00 2001 From: levlam Date: Sun, 29 Oct 2023 01:05:55 +0300 Subject: [PATCH] Don't allow to reply in another chat non-forwardable messages. --- td/generate/scheme/td_api.tl | 4 ++-- td/telegram/MessagesManager.cpp | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index c9f142ed3..bacaba7a1 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 +//@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. A message can be replied in another chat only if message.can_be_forwarded //@message_id The identifier of the message to be replied in the same chat //@quote Manually chosen quote from the replied message; pass null if none; 0-getOption("message_reply_quote_length_max") characters inputMessageReplyToMessage chat_id:int53 message_id:int53 quote:formattedText = InputMessageReplyTo; @@ -1263,7 +1263,7 @@ 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 +//@can_be_forwarded True, if the message can be forwarded or 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 diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index ebbd860f7..94f83e00e 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -24553,11 +24553,16 @@ MessageInputReplyTo MessagesManager::get_message_input_reply_to( if (!for_draft && top_thread_message_id.is_valid() && top_thread_message_id.is_server()) { return MessageInputReplyTo{top_thread_message_id, DialogId(), FormattedText()}; } + LOG(INFO) << "Can't find " << message_id << " in " << reply_d->dialog_id; // TODO local replies to local messages can be allowed // 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)) { + LOG(INFO) << "Can't reply in another chat " << m->message_id << " in " << reply_d->dialog_id; + return {}; + } return MessageInputReplyTo{m->message_id, reply_dialog_id, std::move(quote)}; } default: