From 4e223096da4a7add66a60a41c63ae0c2cefe71ba Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 13 Dec 2019 01:18:07 +0300 Subject: [PATCH] Treat forwarded and via bot messages as copied. GitOrigin-RevId: e3fcd5caea9a08c0a941f549a33356cd9b6075ce --- td/telegram/MessagesManager.cpp | 18 ++++++++---------- td/telegram/MessagesManager.h | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index d55c2ac6..3f951398 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -17288,11 +17288,9 @@ tl_object_ptr MessagesManager::get_messages_object( return td_api::make_object(total_count, std::move(messages)); } -MessagesManager::Message *MessagesManager::get_message_to_send(Dialog *d, MessageId reply_to_message_id, - const SendMessageOptions &options, - unique_ptr &&content, - bool *need_update_dialog_pos, - unique_ptr forward_info) { +MessagesManager::Message *MessagesManager::get_message_to_send( + Dialog *d, MessageId reply_to_message_id, const SendMessageOptions &options, unique_ptr &&content, + bool *need_update_dialog_pos, unique_ptr forward_info, bool is_copy) { CHECK(d != nullptr); CHECK(!reply_to_message_id.is_scheduled()); @@ -17325,6 +17323,7 @@ MessagesManager::Message *MessagesManager::get_message_to_send(Dialog *d, Messag m->views = is_channel_post ? 1 : 0; m->content = std::move(content); m->forward_info = std::move(forward_info); + m->is_copy = is_copy || forward_info != nullptr; if (td_->auth_manager_->is_bot() || options.disable_notification) { m->disable_notification = options.disable_notification; @@ -17888,7 +17887,7 @@ Result MessagesManager::send_message(DialogId dialog_id, MessageId re bool need_update_dialog_pos = false; Message *m = get_message_to_send(d, get_reply_to_message_id(d, reply_to_message_id), send_message_options, dup_message_content(td_, dialog_id, message_content.content.get(), false), - &need_update_dialog_pos); + &need_update_dialog_pos, nullptr, message_content.via_bot_user_id.is_valid()); m->reply_markup = std::move(message_reply_markup); m->via_bot_user_id = message_content.via_bot_user_id; m->disable_web_page_preview = message_content.disable_web_page_preview; @@ -18815,7 +18814,7 @@ Result MessagesManager::send_inline_query_result_message(DialogId dia bool need_update_dialog_pos = false; Message *m = get_message_to_send(d, get_reply_to_message_id(d, reply_to_message_id), send_message_options, dup_message_content(td_, dialog_id, content->message_content.get(), false), - &need_update_dialog_pos); + &need_update_dialog_pos, nullptr, true); m->hide_via_bot = hide_via_bot; if (!hide_via_bot) { m->via_bot_user_id = td_->inline_queries_manager_->get_inline_bot_user_id(query_id); @@ -20464,10 +20463,9 @@ Result> MessagesManager::forward_messages(DialogId to_dialog_i for (auto &copied_message : copied_messages) { Message *m = get_message_to_send(to_dialog, MessageId(), send_message_options, std::move(copied_message.content), - &need_update_dialog_pos); + &need_update_dialog_pos, nullptr, true); m->disable_web_page_preview = copied_message.disable_web_page_preview; m->media_album_id = media_album_id; - m->is_copy = true; save_send_message_logevent(to_dialog_id, m); do_send_message(to_dialog_id, m); @@ -20579,7 +20577,7 @@ Result> MessagesManager::resend_messages(DialogId dialog_id, v SendMessageOptions options(message->disable_notification, message->from_background, get_message_schedule_date(message.get())); Message *m = get_message_to_send(d, get_reply_to_message_id(d, message->reply_to_message_id), options, - std::move(new_contents[i]), &need_update_dialog_pos); + std::move(new_contents[i]), &need_update_dialog_pos, nullptr, message->is_copy); m->reply_markup = std::move(message->reply_markup); m->via_bot_user_id = message->via_bot_user_id; m->disable_web_page_preview = message->disable_web_page_preview; diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 565f84d3..ea10af5b 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -1508,7 +1508,7 @@ class MessagesManager : public Actor { Message *get_message_to_send(Dialog *d, MessageId reply_to_message_id, const SendMessageOptions &options, unique_ptr &&content, bool *need_update_dialog_pos, - unique_ptr forward_info = nullptr); + unique_ptr forward_info = nullptr, bool is_copy = false); int64 begin_send_message(DialogId dialog_id, const Message *m);