From 01d13bf005108dbdc5c8c714547dec98957da9d9 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 23 Apr 2018 01:50:07 +0300 Subject: [PATCH] Update recent hashtags when message is edited. GitOrigin-RevId: ba6dc7bda612d96f9417516fe684d053e68a9e24 --- td/telegram/MessagesManager.cpp | 30 ++++++++++++++++++++---------- td/telegram/MessagesManager.h | 4 ++-- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 0744ebf6..9c50aa61 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -6117,9 +6117,7 @@ void MessagesManager::process_update(tl_object_ptr &&updat on_get_message(std::move(move_tl_object_as(update)->message_), false, false, false, false, "updateEditMessage"); LOG(INFO) << "Process updateEditMessage"; - if (full_message_id != FullMessageId() && td_->auth_manager_->is_bot()) { - send_update_message_edited(full_message_id); - } + on_message_edited(full_message_id); break; } case telegram_api::updateDeleteMessages::ID: { @@ -6191,9 +6189,7 @@ void MessagesManager::process_channel_update(tl_object_ptr on_get_message(std::move(move_tl_object_as(update)->message_), false, true, false, false, "updateEditChannelMessage"); LOG(INFO) << "Process updateEditChannelMessage"; - if (full_message_id != FullMessageId() && td_->auth_manager_->is_bot()) { - send_update_message_edited(full_message_id); - } + on_message_edited(full_message_id); break; } default: @@ -6201,6 +6197,24 @@ void MessagesManager::process_channel_update(tl_object_ptr } } +void MessagesManager::on_message_edited(FullMessageId full_message_id) { + if (full_message_id == FullMessageId()) { + return; + } + + auto dialog_id = full_message_id.get_dialog_id(); + Message *m = get_message(full_message_id); + CHECK(m != nullptr); + if (td_->auth_manager_->is_bot()) { + send_update_message_edited(dialog_id, m); + } else { + if (m->forward_info == nullptr && + (m->is_outgoing || dialog_id == DialogId(td_->contacts_manager_->get_my_id("on_message_edited")))) { + update_used_hashtags(dialog_id, m); + } + } +} + void MessagesManager::process_pending_updates() { for (auto &update : pending_updates_) { process_update(std::move(update.second.update)); @@ -18694,10 +18708,6 @@ void MessagesManager::send_update_message_content(DialogId dialog_id, MessageId dialog_id.get(), message_id.get(), get_message_content_object(content, message_date, is_content_secret))); } -void MessagesManager::send_update_message_edited(FullMessageId full_message_id) { - return send_update_message_edited(full_message_id.get_dialog_id(), get_message(full_message_id)); -} - void MessagesManager::send_update_message_edited(DialogId dialog_id, const Message *m) { CHECK(m != nullptr); cancel_user_dialog_action(dialog_id, m); diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 22a7de52..45534037 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -1932,6 +1932,8 @@ class MessagesManager : public Actor { void process_channel_update(tl_object_ptr &&update); + void on_message_edited(FullMessageId full_message_id); + void delete_messages_from_updates(const vector &message_ids); void delete_dialog_messages_from_updates(DialogId dialog_id, const vector &message_ids); @@ -2166,8 +2168,6 @@ class MessagesManager : public Actor { void send_update_message_content(DialogId dialog_id, MessageId message_id, const MessageContent *content, int32 message_date, bool is_content_secret, const char *source) const; - void send_update_message_edited(FullMessageId full_message_id); - void send_update_message_edited(DialogId dialog_id, const Message *m); void send_update_delete_messages(DialogId dialog_id, vector &&message_ids, bool is_permanent,