diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d2d624a9..ee2f3d262 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -642,7 +642,6 @@ set(TDLIB_SOURCE td/telegram/ForumTopicIcon.h td/telegram/ForumTopicInfo.h td/telegram/ForumTopicManager.h - td/telegram/FullMessageId.h td/telegram/Game.h td/telegram/GameManager.h td/telegram/GitCommitHash.h @@ -676,6 +675,7 @@ set(TDLIB_SOURCE td/telegram/MessageDb.h td/telegram/MessageEntity.h td/telegram/MessageExtendedMedia.h + td/telegram/MessageFullId.h td/telegram/MessageId.h td/telegram/MessageInputReplyTo.h td/telegram/MessageLinkInfo.h diff --git a/td/telegram/CallbackQueriesManager.cpp b/td/telegram/CallbackQueriesManager.cpp index 7566931f1..8806bfe1a 100644 --- a/td/telegram/CallbackQueriesManager.cpp +++ b/td/telegram/CallbackQueriesManager.cpp @@ -228,7 +228,7 @@ void CallbackQueriesManager::on_new_inline_query( std::move(payload))); } -void CallbackQueriesManager::send_callback_query(FullMessageId full_message_id, +void CallbackQueriesManager::send_callback_query(MessageFullId message_full_id, tl_object_ptr &&payload, Promise> &&promise) { if (td_->auth_manager_->is_bot()) { @@ -239,19 +239,19 @@ void CallbackQueriesManager::send_callback_query(FullMessageId full_message_id, return promise.set_error(Status::Error(400, "Payload must be non-empty")); } - auto dialog_id = full_message_id.get_dialog_id(); + auto dialog_id = message_full_id.get_dialog_id(); td_->messages_manager_->have_dialog_force(dialog_id, "send_callback_query"); if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) { return promise.set_error(Status::Error(400, "Can't access the chat")); } - if (!td_->messages_manager_->have_message_force(full_message_id, "send_callback_query")) { + if (!td_->messages_manager_->have_message_force(message_full_id, "send_callback_query")) { return promise.set_error(Status::Error(400, "Message not found")); } - if (full_message_id.get_message_id().is_valid_scheduled()) { + if (message_full_id.get_message_id().is_valid_scheduled()) { return promise.set_error(Status::Error(400, "Can't send callback queries from scheduled messages")); } - if (!full_message_id.get_message_id().is_server()) { + if (!message_full_id.get_message_id().is_server()) { return promise.set_error(Status::Error(400, "Bad message identifier")); } if (dialog_id.get_type() == DialogType::SecretChat) { @@ -262,34 +262,34 @@ void CallbackQueriesManager::send_callback_query(FullMessageId full_message_id, auto password = static_cast(payload.get())->password_; send_closure( td_->password_manager_, &PasswordManager::get_input_check_password_srp, std::move(password), - PromiseCreator::lambda([this, full_message_id, payload = std::move(payload), promise = std::move(promise)]( + PromiseCreator::lambda([this, message_full_id, payload = std::move(payload), promise = std::move(promise)]( Result> result) mutable { if (result.is_error()) { return promise.set_error(result.move_as_error()); } - send_get_callback_answer_query(full_message_id, std::move(payload), result.move_as_ok(), std::move(promise)); + send_get_callback_answer_query(message_full_id, std::move(payload), result.move_as_ok(), std::move(promise)); })); } else { - send_get_callback_answer_query(full_message_id, std::move(payload), nullptr, std::move(promise)); + send_get_callback_answer_query(message_full_id, std::move(payload), nullptr, std::move(promise)); } } void CallbackQueriesManager::send_get_callback_answer_query( - FullMessageId full_message_id, tl_object_ptr &&payload, + MessageFullId message_full_id, tl_object_ptr &&payload, tl_object_ptr &&password, Promise> &&promise) { TRY_STATUS_PROMISE(promise, G()->close_status()); - auto dialog_id = full_message_id.get_dialog_id(); + auto dialog_id = message_full_id.get_dialog_id(); if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) { return promise.set_error(Status::Error(400, "Can't access the chat")); } - if (!td_->messages_manager_->have_message_force(full_message_id, "send_callback_query")) { + if (!td_->messages_manager_->have_message_force(message_full_id, "send_callback_query")) { return promise.set_error(Status::Error(400, "Message not found")); } td_->create_handler(std::move(promise)) - ->send(dialog_id, full_message_id.get_message_id(), payload, std::move(password)); + ->send(dialog_id, message_full_id.get_message_id(), payload, std::move(password)); } } // namespace td diff --git a/td/telegram/CallbackQueriesManager.h b/td/telegram/CallbackQueriesManager.h index cfc36eba4..c9d6b9d02 100644 --- a/td/telegram/CallbackQueriesManager.h +++ b/td/telegram/CallbackQueriesManager.h @@ -7,7 +7,7 @@ #pragma once #include "td/telegram/DialogId.h" -#include "td/telegram/FullMessageId.h" +#include "td/telegram/MessageFullId.h" #include "td/telegram/MessageId.h" #include "td/telegram/td_api.h" #include "td/telegram/telegram_api.h" @@ -35,7 +35,7 @@ class CallbackQueriesManager { tl_object_ptr &&inline_message_id, BufferSlice &&data, int64 chat_instance, string &&game_short_name); - void send_callback_query(FullMessageId full_message_id, tl_object_ptr &&payload, + void send_callback_query(MessageFullId message_full_id, tl_object_ptr &&payload, Promise> &&promise); private: @@ -46,7 +46,7 @@ class CallbackQueriesManager { static tl_object_ptr get_query_payload(int32 flags, BufferSlice &&data, string &&game_short_name); - void send_get_callback_answer_query(FullMessageId full_message_id, + void send_get_callback_answer_query(MessageFullId message_full_id, tl_object_ptr &&payload, tl_object_ptr &&password, Promise> &&promise); diff --git a/td/telegram/ChainId.h b/td/telegram/ChainId.h index 749d9c4f2..e0926b07b 100644 --- a/td/telegram/ChainId.h +++ b/td/telegram/ChainId.h @@ -10,8 +10,8 @@ #include "td/telegram/ChatId.h" #include "td/telegram/DialogId.h" #include "td/telegram/FolderId.h" -#include "td/telegram/FullMessageId.h" #include "td/telegram/MessageContentType.h" +#include "td/telegram/MessageFullId.h" #include "td/telegram/PollId.h" #include "td/telegram/StoryFullId.h" #include "td/telegram/UserId.h" @@ -38,8 +38,8 @@ class ChainId { ChainId(DialogId dialog_id) : id((static_cast(dialog_id.get()) << 10) + 10) { } - ChainId(FullMessageId full_message_id) : ChainId(full_message_id.get_dialog_id()) { - id += static_cast(full_message_id.get_message_id().get()) << 10; + ChainId(MessageFullId message_full_id) : ChainId(message_full_id.get_dialog_id()) { + id += static_cast(message_full_id.get_message_id().get()) << 10; } ChainId(FolderId folder_id) : id((static_cast(folder_id.get() + (1 << 30)) << 10)) { diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 75149c173..2db01219d 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -5327,10 +5327,10 @@ Result> ContactsManager::get_input_user(U auto it = user_messages_.find(user_id); if (it != user_messages_.end()) { CHECK(!it->second.empty()); - auto full_message_id = *it->second.begin(); + auto message_full_id = *it->second.begin(); return make_tl_object( - get_simple_input_peer(full_message_id.get_dialog_id()), - full_message_id.get_message_id().get_server_message_id().get(), user_id.get()); + get_simple_input_peer(message_full_id.get_dialog_id()), + message_full_id.get_message_id().get_server_message_id().get(), user_id.get()); } if (u == nullptr) { return Status::Error(400, "User not found"); @@ -5360,10 +5360,10 @@ tl_object_ptr ContactsManager::get_input_channel(Cha auto it = channel_messages_.find(channel_id); if (it != channel_messages_.end()) { CHECK(!it->second.empty()); - auto full_message_id = *it->second.begin(); + auto message_full_id = *it->second.begin(); return make_tl_object( - get_simple_input_peer(full_message_id.get_dialog_id()), - full_message_id.get_message_id().get_server_message_id().get(), channel_id.get()); + get_simple_input_peer(message_full_id.get_dialog_id()), + message_full_id.get_message_id().get_server_message_id().get(), channel_id.get()); } return nullptr; } @@ -5422,10 +5422,10 @@ tl_object_ptr ContactsManager::get_input_peer_user(User auto it = user_messages_.find(user_id); CHECK(it != user_messages_.end()); CHECK(!it->second.empty()); - auto full_message_id = *it->second.begin(); + auto message_full_id = *it->second.begin(); return make_tl_object( - get_simple_input_peer(full_message_id.get_dialog_id()), - full_message_id.get_message_id().get_server_message_id().get(), user_id.get()); + get_simple_input_peer(message_full_id.get_dialog_id()), + message_full_id.get_message_id().get_server_message_id().get(), user_id.get()); } return make_tl_object(user_id.get(), u->access_hash); @@ -5485,10 +5485,10 @@ tl_object_ptr ContactsManager::get_input_peer_channel(C auto it = channel_messages_.find(channel_id); CHECK(it != channel_messages_.end()); CHECK(!it->second.empty()); - auto full_message_id = *it->second.begin(); + auto message_full_id = *it->second.begin(); return make_tl_object( - get_simple_input_peer(full_message_id.get_dialog_id()), - full_message_id.get_message_id().get_server_message_id().get(), channel_id.get()); + get_simple_input_peer(message_full_id.get_dialog_id()), + message_full_id.get_message_id().get_server_message_id().get(), channel_id.get()); } return make_tl_object(channel_id.get(), c->access_hash); @@ -9530,14 +9530,14 @@ void ContactsManager::remove_inactive_channel(ChannelId channel_id) { } } -void ContactsManager::register_message_users(FullMessageId full_message_id, vector user_ids) { +void ContactsManager::register_message_users(MessageFullId message_full_id, vector user_ids) { for (auto user_id : user_ids) { CHECK(user_id.is_valid()); const User *u = get_user(user_id); if (u == nullptr || u->access_hash == -1 || u->is_min_access_hash) { auto &user_messages = user_messages_[user_id]; auto need_update = user_messages.empty(); - user_messages.insert(full_message_id); + user_messages.insert(message_full_id); if (need_update) { send_closure(G()->td(), &Td::send_update, get_update_user_object(user_id, u)); } @@ -9545,12 +9545,12 @@ void ContactsManager::register_message_users(FullMessageId full_message_id, vect } } -void ContactsManager::register_message_channels(FullMessageId full_message_id, vector channel_ids) { +void ContactsManager::register_message_channels(MessageFullId message_full_id, vector channel_ids) { for (auto channel_id : channel_ids) { CHECK(channel_id.is_valid()); const Channel *c = get_channel(channel_id); if (c == nullptr) { - channel_messages_[channel_id].insert(full_message_id); + channel_messages_[channel_id].insert(message_full_id); // get info about the channel get_channel_queries_.add_query(channel_id.get(), Promise()); @@ -9558,7 +9558,7 @@ void ContactsManager::register_message_channels(FullMessageId full_message_id, v } } -void ContactsManager::unregister_message_users(FullMessageId full_message_id, vector user_ids) { +void ContactsManager::unregister_message_users(MessageFullId message_full_id, vector user_ids) { if (user_messages_.empty()) { // fast path return; @@ -9566,7 +9566,7 @@ void ContactsManager::unregister_message_users(FullMessageId full_message_id, ve for (auto user_id : user_ids) { auto it = user_messages_.find(user_id); if (it != user_messages_.end()) { - it->second.erase(full_message_id); + it->second.erase(message_full_id); if (it->second.empty()) { user_messages_.erase(it); @@ -9579,7 +9579,7 @@ void ContactsManager::unregister_message_users(FullMessageId full_message_id, ve } } -void ContactsManager::unregister_message_channels(FullMessageId full_message_id, vector channel_ids) { +void ContactsManager::unregister_message_channels(MessageFullId message_full_id, vector channel_ids) { if (channel_messages_.empty()) { // fast path return; @@ -9587,7 +9587,7 @@ void ContactsManager::unregister_message_channels(FullMessageId full_message_id, for (auto channel_id : channel_ids) { auto it = channel_messages_.find(channel_id); if (it != channel_messages_.end()) { - it->second.erase(full_message_id); + it->second.erase(message_full_id); if (it->second.empty()) { channel_messages_.erase(it); } diff --git a/td/telegram/ContactsManager.h b/td/telegram/ContactsManager.h index 45decfd49..94a50f0e9 100644 --- a/td/telegram/ContactsManager.h +++ b/td/telegram/ContactsManager.h @@ -23,8 +23,8 @@ #include "td/telegram/files/FileId.h" #include "td/telegram/files/FileSourceId.h" #include "td/telegram/FolderId.h" -#include "td/telegram/FullMessageId.h" #include "td/telegram/Location.h" +#include "td/telegram/MessageFullId.h" #include "td/telegram/MessageId.h" #include "td/telegram/net/DcId.h" #include "td/telegram/Photo.h" @@ -282,13 +282,13 @@ class ContactsManager final : public Actor { void remove_inactive_channel(ChannelId channel_id); - void register_message_users(FullMessageId full_message_id, vector user_ids); + void register_message_users(MessageFullId message_full_id, vector user_ids); - void register_message_channels(FullMessageId full_message_id, vector channel_ids); + void register_message_channels(MessageFullId message_full_id, vector channel_ids); - void unregister_message_users(FullMessageId full_message_id, vector user_ids); + void unregister_message_users(MessageFullId message_full_id, vector user_ids); - void unregister_message_channels(FullMessageId full_message_id, vector channel_ids); + void unregister_message_channels(MessageFullId message_full_id, vector channel_ids); UserId get_my_id() const; @@ -2023,8 +2023,8 @@ class ContactsManager final : public Actor { FlatHashMap resolved_phone_numbers_; - FlatHashMap, UserIdHash> user_messages_; - FlatHashMap, ChannelIdHash> channel_messages_; + FlatHashMap, UserIdHash> user_messages_; + FlatHashMap, ChannelIdHash> channel_messages_; // bot-administrators only struct ChannelParticipantInfo { diff --git a/td/telegram/FileReferenceManager.cpp b/td/telegram/FileReferenceManager.cpp index 9c3a692c1..72df5442b 100644 --- a/td/telegram/FileReferenceManager.cpp +++ b/td/telegram/FileReferenceManager.cpp @@ -92,9 +92,9 @@ FileSourceId FileReferenceManager::add_file_source_id(T &source, Slice source_st return get_current_file_source_id(); } -FileSourceId FileReferenceManager::create_message_file_source(FullMessageId full_message_id) { - FileSourceMessage source{full_message_id}; - return add_file_source_id(source, PSLICE() << full_message_id); +FileSourceId FileReferenceManager::create_message_file_source(MessageFullId message_full_id) { + FileSourceMessage source{message_full_id}; + return add_file_source_id(source, PSLICE() << message_full_id); } FileSourceId FileReferenceManager::create_user_photo_file_source(UserId user_id, int64 photo_id) { @@ -204,16 +204,16 @@ vector FileReferenceManager::get_some_file_sources(NodeId node_id) return node->file_source_ids.get_some_elements(); } -vector FileReferenceManager::get_some_message_file_sources(NodeId node_id) { +vector FileReferenceManager::get_some_message_file_sources(NodeId node_id) { auto file_source_ids = get_some_file_sources(node_id); - vector result; + vector result; for (auto file_source_id : file_source_ids) { auto index = static_cast(file_source_id.get()) - 1; CHECK(index < file_sources_.size()); const auto &file_source = file_sources_[index]; if (file_source.get_offset() == 0) { - result.push_back(file_source.get().full_message_id); + result.push_back(file_source.get().message_full_id); } } return result; @@ -312,7 +312,7 @@ void FileReferenceManager::send_query(Destination dest, FileSourceId file_source CHECK(index < file_sources_.size()); file_sources_[index].visit(overloaded( [&](const FileSourceMessage &source) { - send_closure_later(G()->messages_manager(), &MessagesManager::get_message_from_server, source.full_message_id, + send_closure_later(G()->messages_manager(), &MessagesManager::get_message_from_server, source.message_full_id, std::move(promise), "FileSourceMessage", nullptr); }, [&](const FileSourceUserPhoto &source) { @@ -475,7 +475,7 @@ void FileReferenceManager::get_file_search_text(FileSourceId file_source_id, str file_sources_[index].visit(overloaded( [&](const FileSourceMessage &source) { send_closure_later(G()->messages_manager(), &MessagesManager::get_message_file_search_text, - source.full_message_id, std::move(unique_file_id), std::move(promise)); + source.message_full_id, std::move(unique_file_id), std::move(promise)); }, [&](const auto &source) { promise.set_error(Status::Error(500, "Unsupported file source")); })); } @@ -486,7 +486,7 @@ td_api::object_ptr FileReferenceManager::get_message_object(Fil td_api::object_ptr result; file_sources_[index].visit(overloaded( [&](const FileSourceMessage &source) { - result = G()->td().get_actor_unsafe()->messages_manager_->get_message_object(source.full_message_id, + result = G()->td().get_actor_unsafe()->messages_manager_->get_message_object(source.message_full_id, "FileReferenceManager"); }, [&](const auto &source) { LOG(ERROR) << "Unsupported file source"; })); diff --git a/td/telegram/FileReferenceManager.h b/td/telegram/FileReferenceManager.h index 01ce1d001..e9624adb5 100644 --- a/td/telegram/FileReferenceManager.h +++ b/td/telegram/FileReferenceManager.h @@ -11,7 +11,7 @@ #include "td/telegram/ChatId.h" #include "td/telegram/files/FileId.h" #include "td/telegram/files/FileSourceId.h" -#include "td/telegram/FullMessageId.h" +#include "td/telegram/MessageFullId.h" #include "td/telegram/PhotoSizeSource.h" #include "td/telegram/SetWithPosition.h" #include "td/telegram/StoryFullId.h" @@ -47,7 +47,7 @@ class FileReferenceManager final : public Actor { static bool is_file_reference_error(const Status &error); static size_t get_file_reference_error_pos(const Status &error); - FileSourceId create_message_file_source(FullMessageId full_message_id); + FileSourceId create_message_file_source(MessageFullId message_full_id); FileSourceId create_user_photo_file_source(UserId user_id, int64 photo_id); // file reference aren't used for chat/channel photo download and the photos can't be reused // FileSourceId create_chat_photo_file_source(ChatId chat_id); @@ -80,7 +80,7 @@ class FileReferenceManager final : public Actor { vector get_some_file_sources(NodeId node_id); - vector get_some_message_file_sources(NodeId node_id); + vector get_some_message_file_sources(NodeId node_id); bool remove_file_source(NodeId node_id, FileSourceId file_source_id); @@ -118,7 +118,7 @@ class FileReferenceManager final : public Actor { }; struct FileSourceMessage { - FullMessageId full_message_id; + MessageFullId message_full_id; }; struct FileSourceUserPhoto { int64 photo_id; diff --git a/td/telegram/FileReferenceManager.hpp b/td/telegram/FileReferenceManager.hpp index 30839b874..6d4c4281e 100644 --- a/td/telegram/FileReferenceManager.hpp +++ b/td/telegram/FileReferenceManager.hpp @@ -14,7 +14,7 @@ #include "td/telegram/ContactsManager.h" #include "td/telegram/FileReferenceManager.h" #include "td/telegram/files/FileSourceId.h" -#include "td/telegram/FullMessageId.h" +#include "td/telegram/MessageFullId.h" #include "td/telegram/MessagesManager.h" #include "td/telegram/NotificationSettingsManager.h" #include "td/telegram/StickersManager.h" @@ -36,7 +36,7 @@ void FileReferenceManager::store_file_source(FileSourceId file_source_id, Storer CHECK(index < file_sources_.size()); auto &source = file_sources_[index]; td::store(source.get_offset(), storer); - source.visit(overloaded([&](const FileSourceMessage &source) { td::store(source.full_message_id, storer); }, + source.visit(overloaded([&](const FileSourceMessage &source) { td::store(source.message_full_id, storer); }, [&](const FileSourceUserPhoto &source) { td::store(source.user_id, storer); td::store(source.photo_id, storer); @@ -69,9 +69,9 @@ FileSourceId FileReferenceManager::parse_file_source(Td *td, ParserT &parser) { auto type = parser.fetch_int(); switch (type) { case 0: { - FullMessageId full_message_id; - td::parse(full_message_id, parser); - return td->messages_manager_->get_message_file_source_id(full_message_id); + MessageFullId message_full_id; + td::parse(message_full_id, parser); + return td->messages_manager_->get_message_file_source_id(message_full_id); } case 1: { UserId user_id; diff --git a/td/telegram/GameManager.cpp b/td/telegram/GameManager.cpp index 9fa92460a..bace60a9e 100644 --- a/td/telegram/GameManager.cpp +++ b/td/telegram/GameManager.cpp @@ -198,39 +198,39 @@ void GameManager::tear_down() { parent_.reset(); } -void GameManager::set_game_score(FullMessageId full_message_id, bool edit_message, UserId user_id, int32 score, +void GameManager::set_game_score(MessageFullId message_full_id, bool edit_message, UserId user_id, int32 score, bool force, Promise> &&promise) { CHECK(td_->auth_manager_->is_bot()); - if (!td_->messages_manager_->have_message_force(full_message_id, "set_game_score")) { + if (!td_->messages_manager_->have_message_force(message_full_id, "set_game_score")) { return promise.set_error(Status::Error(400, "Message not found")); } - auto dialog_id = full_message_id.get_dialog_id(); + auto dialog_id = message_full_id.get_dialog_id(); if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Edit)) { return promise.set_error(Status::Error(400, "Can't access the chat")); } TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(user_id)); - if (!td_->messages_manager_->can_set_game_score(full_message_id)) { + if (!td_->messages_manager_->can_set_game_score(message_full_id)) { return promise.set_error(Status::Error(400, "Game score can't be set")); } auto query_promise = PromiseCreator::lambda( - [actor_id = actor_id(this), full_message_id, promise = std::move(promise)](Result &&result) mutable { + [actor_id = actor_id(this), message_full_id, promise = std::move(promise)](Result &&result) mutable { if (result.is_error()) { return promise.set_error(result.move_as_error()); } - send_closure(actor_id, &GameManager::on_set_game_score, full_message_id, std::move(promise)); + send_closure(actor_id, &GameManager::on_set_game_score, message_full_id, std::move(promise)); }); td_->create_handler(std::move(query_promise)) - ->send(dialog_id, full_message_id.get_message_id(), edit_message, std::move(input_user), score, force); + ->send(dialog_id, message_full_id.get_message_id(), edit_message, std::move(input_user), score, force); } -void GameManager::on_set_game_score(FullMessageId full_message_id, +void GameManager::on_set_game_score(MessageFullId message_full_id, Promise> &&promise) { - promise.set_value(td_->messages_manager_->get_message_object(full_message_id, "on_set_game_score")); + promise.set_value(td_->messages_manager_->get_message_object(message_full_id, "on_set_game_score")); } void GameManager::set_inline_game_score(const string &inline_message_id, bool edit_message, UserId user_id, int32 score, @@ -248,19 +248,19 @@ void GameManager::set_inline_game_score(const string &inline_message_id, bool ed ->send(std::move(input_bot_inline_message_id), edit_message, std::move(input_user), score, force); } -void GameManager::get_game_high_scores(FullMessageId full_message_id, UserId user_id, +void GameManager::get_game_high_scores(MessageFullId message_full_id, UserId user_id, Promise> &&promise) { CHECK(td_->auth_manager_->is_bot()); - if (!td_->messages_manager_->have_message_force(full_message_id, "get_game_high_scores")) { + if (!td_->messages_manager_->have_message_force(message_full_id, "get_game_high_scores")) { return promise.set_error(Status::Error(400, "Message not found")); } - auto dialog_id = full_message_id.get_dialog_id(); + auto dialog_id = message_full_id.get_dialog_id(); if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) { return promise.set_error(Status::Error(400, "Can't access the chat")); } - auto message_id = full_message_id.get_message_id(); + auto message_id = message_full_id.get_message_id(); if (message_id.is_scheduled() || !message_id.is_server() || dialog_id.get_type() == DialogType::SecretChat) { return promise.set_error(Status::Error(400, "Wrong message identifier specified")); } diff --git a/td/telegram/GameManager.h b/td/telegram/GameManager.h index 6eac8a151..d9c5e10d8 100644 --- a/td/telegram/GameManager.h +++ b/td/telegram/GameManager.h @@ -6,7 +6,7 @@ // #pragma once -#include "td/telegram/FullMessageId.h" +#include "td/telegram/MessageFullId.h" #include "td/telegram/td_api.h" #include "td/telegram/telegram_api.h" #include "td/telegram/UserId.h" @@ -29,13 +29,13 @@ class GameManager final : public Actor { GameManager &operator=(GameManager &&) = delete; ~GameManager() final; - void set_game_score(FullMessageId full_message_id, bool edit_message, UserId user_id, int32 score, bool force, + void set_game_score(MessageFullId message_full_id, bool edit_message, UserId user_id, int32 score, bool force, Promise> &&promise); void set_inline_game_score(const string &inline_message_id, bool edit_message, UserId user_id, int32 score, bool force, Promise &&promise); - void get_game_high_scores(FullMessageId full_message_id, UserId user_id, + void get_game_high_scores(MessageFullId message_full_id, UserId user_id, Promise> &&promise); void get_inline_game_high_scores(const string &inline_message_id, UserId user_id, @@ -47,7 +47,7 @@ class GameManager final : public Actor { private: void tear_down() final; - void on_set_game_score(FullMessageId full_message_id, Promise> &&promise); + void on_set_game_score(MessageFullId message_full_id, Promise> &&promise); Td *td_; ActorShared<> parent_; diff --git a/td/telegram/LinkManager.cpp b/td/telegram/LinkManager.cpp index 5c550bee3..b23cb2e92 100644 --- a/td/telegram/LinkManager.cpp +++ b/td/telegram/LinkManager.cpp @@ -823,12 +823,12 @@ class RequestUrlAuthQuery final : public Td::ResultHandler { : promise_(std::move(promise)) { } - void send(string url, FullMessageId full_message_id, int32 button_id) { + void send(string url, MessageFullId message_full_id, int32 button_id) { url_ = std::move(url); int32 flags = 0; tl_object_ptr input_peer; - if (full_message_id.get_dialog_id().is_valid()) { - dialog_id_ = full_message_id.get_dialog_id(); + if (message_full_id.get_dialog_id().is_valid()) { + dialog_id_ = message_full_id.get_dialog_id(); input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read); CHECK(input_peer != nullptr); flags |= telegram_api::messages_requestUrlAuth::PEER_MASK; @@ -836,7 +836,7 @@ class RequestUrlAuthQuery final : public Td::ResultHandler { flags |= telegram_api::messages_requestUrlAuth::URL_MASK; } send_query(G()->net_query_creator().create(telegram_api::messages_requestUrlAuth( - flags, std::move(input_peer), full_message_id.get_message_id().get_server_message_id().get(), button_id, + flags, std::move(input_peer), message_full_id.get_message_id().get_server_message_id().get(), button_id, url_))); } @@ -890,12 +890,12 @@ class AcceptUrlAuthQuery final : public Td::ResultHandler { explicit AcceptUrlAuthQuery(Promise> &&promise) : promise_(std::move(promise)) { } - void send(string url, FullMessageId full_message_id, int32 button_id, bool allow_write_access) { + void send(string url, MessageFullId message_full_id, int32 button_id, bool allow_write_access) { url_ = std::move(url); int32 flags = 0; tl_object_ptr input_peer; - if (full_message_id.get_dialog_id().is_valid()) { - dialog_id_ = full_message_id.get_dialog_id(); + if (message_full_id.get_dialog_id().is_valid()) { + dialog_id_ = message_full_id.get_dialog_id(); input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read); CHECK(input_peer != nullptr); flags |= telegram_api::messages_acceptUrlAuth::PEER_MASK; @@ -906,7 +906,7 @@ class AcceptUrlAuthQuery final : public Td::ResultHandler { flags |= telegram_api::messages_acceptUrlAuth::WRITE_ALLOWED_MASK; } send_query(G()->net_query_creator().create(telegram_api::messages_acceptUrlAuth( - flags, false /*ignored*/, std::move(input_peer), full_message_id.get_message_id().get_server_message_id().get(), + flags, false /*ignored*/, std::move(input_peer), message_full_id.get_message_id().get_server_message_id().get(), button_id, url_))); } @@ -2386,7 +2386,7 @@ void LinkManager::get_external_link_info(string &&link, Promisecreate_handler(std::move(promise))->send(link, FullMessageId(), 0); + td_->create_handler(std::move(promise))->send(link, MessageFullId(), 0); return; } return promise.set_value(std::move(default_result)); @@ -2431,23 +2431,23 @@ void LinkManager::get_external_link_info(string &&link, Promise(url.get_url(), skip_confirmation)); } -void LinkManager::get_login_url_info(FullMessageId full_message_id, int64 button_id, +void LinkManager::get_login_url_info(MessageFullId message_full_id, int64 button_id, Promise> &&promise) { - TRY_RESULT_PROMISE(promise, url, td_->messages_manager_->get_login_button_url(full_message_id, button_id)); + TRY_RESULT_PROMISE(promise, url, td_->messages_manager_->get_login_button_url(message_full_id, button_id)); td_->create_handler(std::move(promise)) - ->send(std::move(url), full_message_id, narrow_cast(button_id)); + ->send(std::move(url), message_full_id, narrow_cast(button_id)); } -void LinkManager::get_login_url(FullMessageId full_message_id, int64 button_id, bool allow_write_access, +void LinkManager::get_login_url(MessageFullId message_full_id, int64 button_id, bool allow_write_access, Promise> &&promise) { - TRY_RESULT_PROMISE(promise, url, td_->messages_manager_->get_login_button_url(full_message_id, button_id)); + TRY_RESULT_PROMISE(promise, url, td_->messages_manager_->get_login_button_url(message_full_id, button_id)); td_->create_handler(std::move(promise)) - ->send(std::move(url), full_message_id, narrow_cast(button_id), allow_write_access); + ->send(std::move(url), message_full_id, narrow_cast(button_id), allow_write_access); } void LinkManager::get_link_login_url(const string &url, bool allow_write_access, Promise> &&promise) { - td_->create_handler(std::move(promise))->send(url, FullMessageId(), 0, allow_write_access); + td_->create_handler(std::move(promise))->send(url, MessageFullId(), 0, allow_write_access); } Result LinkManager::get_background_url(const string &name, diff --git a/td/telegram/LinkManager.h b/td/telegram/LinkManager.h index 1cc1773d3..a8ea75a7d 100644 --- a/td/telegram/LinkManager.h +++ b/td/telegram/LinkManager.h @@ -8,7 +8,7 @@ #include "td/telegram/CustomEmojiId.h" #include "td/telegram/DialogBoostLinkInfo.h" -#include "td/telegram/FullMessageId.h" +#include "td/telegram/MessageFullId.h" #include "td/telegram/MessageLinkInfo.h" #include "td/telegram/td_api.h" #include "td/telegram/UserId.h" @@ -72,10 +72,10 @@ class LinkManager final : public Actor { void get_external_link_info(string &&link, Promise> &&promise); - void get_login_url_info(FullMessageId full_message_id, int64 button_id, + void get_login_url_info(MessageFullId message_full_id, int64 button_id, Promise> &&promise); - void get_login_url(FullMessageId full_message_id, int64 button_id, bool allow_write_access, + void get_login_url(MessageFullId message_full_id, int64 button_id, bool allow_write_access, Promise> &&promise); void get_link_login_url(const string &url, bool allow_write_access, diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index 36b63f0af..77b469107 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -3316,7 +3316,7 @@ string get_message_content_theme_name(const MessageContent *content) { } } -FullMessageId get_message_content_replied_message_id(DialogId dialog_id, const MessageContent *content) { +MessageFullId get_message_content_replied_message_id(DialogId dialog_id, const MessageContent *content) { switch (content->get_type()) { case MessageContentType::PinMessage: return {dialog_id, static_cast(content)->message_id}; @@ -3325,7 +3325,7 @@ FullMessageId get_message_content_replied_message_id(DialogId dialog_id, const M case MessageContentType::PaymentSuccessful: { auto *m = static_cast(content); if (!m->invoice_message_id.is_valid()) { - return FullMessageId(); + return MessageFullId(); } auto reply_in_dialog_id = m->invoice_dialog_id.is_valid() ? m->invoice_dialog_id : dialog_id; @@ -3334,13 +3334,13 @@ FullMessageId get_message_content_replied_message_id(DialogId dialog_id, const M case MessageContentType::SetBackground: { auto *m = static_cast(content); if (!m->old_message_id.is_valid()) { - return FullMessageId(); + return MessageFullId(); } return {dialog_id, m->old_message_id}; } default: - return FullMessageId(); + return MessageFullId(); } } @@ -3585,25 +3585,25 @@ bool can_message_content_have_media_timestamp(const MessageContent *content) { } } -void set_message_content_poll_answer(Td *td, const MessageContent *content, FullMessageId full_message_id, +void set_message_content_poll_answer(Td *td, const MessageContent *content, MessageFullId message_full_id, vector &&option_ids, Promise &&promise) { CHECK(content->get_type() == MessageContentType::Poll); - td->poll_manager_->set_poll_answer(static_cast(content)->poll_id, full_message_id, + td->poll_manager_->set_poll_answer(static_cast(content)->poll_id, message_full_id, std::move(option_ids), std::move(promise)); } -void get_message_content_poll_voters(Td *td, const MessageContent *content, FullMessageId full_message_id, +void get_message_content_poll_voters(Td *td, const MessageContent *content, MessageFullId message_full_id, int32 option_id, int32 offset, int32 limit, Promise> &&promise) { CHECK(content->get_type() == MessageContentType::Poll); - td->poll_manager_->get_poll_voters(static_cast(content)->poll_id, full_message_id, option_id, + td->poll_manager_->get_poll_voters(static_cast(content)->poll_id, message_full_id, option_id, offset, limit, std::move(promise)); } -void stop_message_content_poll(Td *td, const MessageContent *content, FullMessageId full_message_id, +void stop_message_content_poll(Td *td, const MessageContent *content, MessageFullId message_full_id, unique_ptr &&reply_markup, Promise &&promise) { CHECK(content->get_type() == MessageContentType::Poll); - td->poll_manager_->stop_poll(static_cast(content)->poll_id, full_message_id, + td->poll_manager_->stop_poll(static_cast(content)->poll_id, message_full_id, std::move(reply_markup), std::move(promise)); } @@ -4372,48 +4372,48 @@ static CustomEmojiId get_custom_emoji_id(const FormattedText &text) { return text.entities.empty() ? CustomEmojiId() : text.entities[0].custom_emoji_id; } -void register_message_content(Td *td, const MessageContent *content, FullMessageId full_message_id, +void register_message_content(Td *td, const MessageContent *content, MessageFullId message_full_id, const char *source) { switch (content->get_type()) { case MessageContentType::Text: { auto text = static_cast(content); if (text->web_page_id.is_valid()) { - td->web_pages_manager_->register_web_page(text->web_page_id, full_message_id, source); + td->web_pages_manager_->register_web_page(text->web_page_id, message_full_id, source); } else if (can_be_animated_emoji(text->text)) { - td->stickers_manager_->register_emoji(text->text.text, get_custom_emoji_id(text->text), full_message_id, + td->stickers_manager_->register_emoji(text->text.text, get_custom_emoji_id(text->text), message_full_id, source); } return; } case MessageContentType::VideoNote: return td->video_notes_manager_->register_video_note(static_cast(content)->file_id, - full_message_id, source); + message_full_id, source); case MessageContentType::VoiceNote: return td->voice_notes_manager_->register_voice_note(static_cast(content)->file_id, - full_message_id, source); + message_full_id, source); case MessageContentType::Poll: - return td->poll_manager_->register_poll(static_cast(content)->poll_id, full_message_id, + return td->poll_manager_->register_poll(static_cast(content)->poll_id, message_full_id, source); case MessageContentType::Dice: { auto dice = static_cast(content); - return td->stickers_manager_->register_dice(dice->emoji, dice->dice_value, full_message_id, source); + return td->stickers_manager_->register_dice(dice->emoji, dice->dice_value, message_full_id, source); } case MessageContentType::GiftPremium: return td->stickers_manager_->register_premium_gift(static_cast(content)->months, - full_message_id, source); + message_full_id, source); case MessageContentType::SuggestProfilePhoto: return td->contacts_manager_->register_suggested_profile_photo( static_cast(content)->photo); case MessageContentType::Story: return td->story_manager_->register_story(static_cast(content)->story_full_id, - full_message_id, source); + message_full_id, source); default: return; } } void reregister_message_content(Td *td, const MessageContent *old_content, const MessageContent *new_content, - FullMessageId full_message_id, const char *source) { + MessageFullId message_full_id, const char *source) { auto old_content_type = old_content->get_type(); auto new_content_type = new_content->get_type(); if (old_content_type == new_content_type) { @@ -4470,42 +4470,42 @@ void reregister_message_content(Td *td, const MessageContent *old_content, const return; } } - unregister_message_content(td, old_content, full_message_id, source); - register_message_content(td, new_content, full_message_id, source); + unregister_message_content(td, old_content, message_full_id, source); + register_message_content(td, new_content, message_full_id, source); } -void unregister_message_content(Td *td, const MessageContent *content, FullMessageId full_message_id, +void unregister_message_content(Td *td, const MessageContent *content, MessageFullId message_full_id, const char *source) { switch (content->get_type()) { case MessageContentType::Text: { auto text = static_cast(content); if (text->web_page_id.is_valid()) { - td->web_pages_manager_->unregister_web_page(text->web_page_id, full_message_id, source); + td->web_pages_manager_->unregister_web_page(text->web_page_id, message_full_id, source); } else if (can_be_animated_emoji(text->text)) { - td->stickers_manager_->unregister_emoji(text->text.text, get_custom_emoji_id(text->text), full_message_id, + td->stickers_manager_->unregister_emoji(text->text.text, get_custom_emoji_id(text->text), message_full_id, source); } return; } case MessageContentType::VideoNote: return td->video_notes_manager_->unregister_video_note(static_cast(content)->file_id, - full_message_id, source); + message_full_id, source); case MessageContentType::VoiceNote: return td->voice_notes_manager_->unregister_voice_note(static_cast(content)->file_id, - full_message_id, source); + message_full_id, source); case MessageContentType::Poll: - return td->poll_manager_->unregister_poll(static_cast(content)->poll_id, full_message_id, + return td->poll_manager_->unregister_poll(static_cast(content)->poll_id, message_full_id, source); case MessageContentType::Dice: { auto dice = static_cast(content); - return td->stickers_manager_->unregister_dice(dice->emoji, dice->dice_value, full_message_id, source); + return td->stickers_manager_->unregister_dice(dice->emoji, dice->dice_value, message_full_id, source); } case MessageContentType::GiftPremium: return td->stickers_manager_->unregister_premium_gift(static_cast(content)->months, - full_message_id, source); + message_full_id, source); case MessageContentType::Story: return td->story_manager_->unregister_story(static_cast(content)->story_full_id, - full_message_id, source); + message_full_id, source); default: return; } @@ -6539,7 +6539,7 @@ bool need_poll_message_content_extended_media(const MessageContent *content) { return static_cast(content)->input_invoice.need_poll_extended_media(); } -void get_message_content_animated_emoji_click_sticker(const MessageContent *content, FullMessageId full_message_id, +void get_message_content_animated_emoji_click_sticker(const MessageContent *content, MessageFullId message_full_id, Td *td, Promise> &&promise) { if (content->get_type() != MessageContentType::Text) { return promise.set_error(Status::Error(400, "Message is not an animated emoji message")); @@ -6549,10 +6549,10 @@ void get_message_content_animated_emoji_click_sticker(const MessageContent *cont if (!can_be_animated_emoji(text)) { return promise.set_error(Status::Error(400, "Message is not an animated emoji message")); } - td->stickers_manager_->get_animated_emoji_click_sticker(text.text, full_message_id, std::move(promise)); + td->stickers_manager_->get_animated_emoji_click_sticker(text.text, message_full_id, std::move(promise)); } -void on_message_content_animated_emoji_clicked(const MessageContent *content, FullMessageId full_message_id, Td *td, +void on_message_content_animated_emoji_clicked(const MessageContent *content, MessageFullId message_full_id, Td *td, string &&emoji, string &&data) { if (content->get_type() != MessageContentType::Text) { return; @@ -6563,7 +6563,7 @@ void on_message_content_animated_emoji_clicked(const MessageContent *content, Fu if (!text.entities.empty() || remove_emoji_modifiers(text.text) != emoji) { return; } - auto error = td->stickers_manager_->on_animated_emoji_message_clicked(std::move(emoji), full_message_id, data); + auto error = td->stickers_manager_->on_animated_emoji_message_clicked(std::move(emoji), message_full_id, data); if (error.is_error()) { LOG(WARNING) << "Failed to process animated emoji click with data \"" << data << "\": " << error; } @@ -6927,25 +6927,25 @@ void update_used_hashtags(Td *td, const MessageContent *content) { } } -void recognize_message_content_speech(Td *td, const MessageContent *content, FullMessageId full_message_id, +void recognize_message_content_speech(Td *td, const MessageContent *content, MessageFullId message_full_id, Promise &&promise) { switch (content->get_type()) { case MessageContentType::VideoNote: - return td->video_notes_manager_->recognize_speech(full_message_id, std::move(promise)); + return td->video_notes_manager_->recognize_speech(message_full_id, std::move(promise)); case MessageContentType::VoiceNote: - return td->voice_notes_manager_->recognize_speech(full_message_id, std::move(promise)); + return td->voice_notes_manager_->recognize_speech(message_full_id, std::move(promise)); default: return promise.set_error(Status::Error(400, "Invalid message specified")); } } -void rate_message_content_speech_recognition(Td *td, const MessageContent *content, FullMessageId full_message_id, +void rate_message_content_speech_recognition(Td *td, const MessageContent *content, MessageFullId message_full_id, bool is_good, Promise &&promise) { switch (content->get_type()) { case MessageContentType::VideoNote: - return td->video_notes_manager_->rate_speech_recognition(full_message_id, is_good, std::move(promise)); + return td->video_notes_manager_->rate_speech_recognition(message_full_id, is_good, std::move(promise)); case MessageContentType::VoiceNote: - return td->voice_notes_manager_->rate_speech_recognition(full_message_id, is_good, std::move(promise)); + return td->voice_notes_manager_->rate_speech_recognition(message_full_id, is_good, std::move(promise)); default: return promise.set_error(Status::Error(400, "Invalid message specified")); } diff --git a/td/telegram/MessageContent.h b/td/telegram/MessageContent.h index 40618df15..a3812e9e1 100644 --- a/td/telegram/MessageContent.h +++ b/td/telegram/MessageContent.h @@ -10,12 +10,12 @@ #include "td/telegram/DialogId.h" #include "td/telegram/EncryptedFile.h" #include "td/telegram/files/FileId.h" -#include "td/telegram/FullMessageId.h" #include "td/telegram/InputGroupCallId.h" #include "td/telegram/logevent/LogEvent.h" #include "td/telegram/MessageContentType.h" #include "td/telegram/MessageCopyOptions.h" #include "td/telegram/MessageEntity.h" +#include "td/telegram/MessageFullId.h" #include "td/telegram/MessageId.h" #include "td/telegram/Photo.h" #include "td/telegram/ReplyMarkup.h" @@ -142,7 +142,7 @@ BackgroundInfo get_message_content_background_info(const MessageContent *content string get_message_content_theme_name(const MessageContent *content); -FullMessageId get_message_content_replied_message_id(DialogId dialog_id, const MessageContent *content); +MessageFullId get_message_content_replied_message_id(DialogId dialog_id, const MessageContent *content); std::pair get_message_content_group_call_info(const MessageContent *content); @@ -166,14 +166,14 @@ void remove_message_content_web_page(MessageContent *content); bool can_message_content_have_media_timestamp(const MessageContent *content); -void set_message_content_poll_answer(Td *td, const MessageContent *content, FullMessageId full_message_id, +void set_message_content_poll_answer(Td *td, const MessageContent *content, MessageFullId message_full_id, vector &&option_ids, Promise &&promise); -void get_message_content_poll_voters(Td *td, const MessageContent *content, FullMessageId full_message_id, +void get_message_content_poll_voters(Td *td, const MessageContent *content, MessageFullId message_full_id, int32 option_id, int32 offset, int32 limit, Promise> &&promise); -void stop_message_content_poll(Td *td, const MessageContent *content, FullMessageId full_message_id, +void stop_message_content_poll(Td *td, const MessageContent *content, MessageFullId message_full_id, unique_ptr &&reply_markup, Promise &&promise); void merge_message_contents(Td *td, const MessageContent *old_content, MessageContent *new_content, @@ -182,12 +182,12 @@ void merge_message_contents(Td *td, const MessageContent *old_content, MessageCo bool merge_message_content_file_id(Td *td, MessageContent *message_content, FileId new_file_id); -void register_message_content(Td *td, const MessageContent *content, FullMessageId full_message_id, const char *source); +void register_message_content(Td *td, const MessageContent *content, MessageFullId message_full_id, const char *source); void reregister_message_content(Td *td, const MessageContent *old_content, const MessageContent *new_content, - FullMessageId full_message_id, const char *source); + MessageFullId message_full_id, const char *source); -void unregister_message_content(Td *td, const MessageContent *content, FullMessageId full_message_id, +void unregister_message_content(Td *td, const MessageContent *content, MessageFullId message_full_id, const char *source); unique_ptr get_secret_message_content( @@ -251,10 +251,10 @@ bool update_message_content_extended_media(MessageContent *content, bool need_poll_message_content_extended_media(const MessageContent *content); -void get_message_content_animated_emoji_click_sticker(const MessageContent *content, FullMessageId full_message_id, +void get_message_content_animated_emoji_click_sticker(const MessageContent *content, MessageFullId message_full_id, Td *td, Promise> &&promise); -void on_message_content_animated_emoji_clicked(const MessageContent *content, FullMessageId full_message_id, Td *td, +void on_message_content_animated_emoji_clicked(const MessageContent *content, MessageFullId message_full_id, Td *td, string &&emoji, string &&data); bool need_reget_message_content(const MessageContent *content); @@ -282,10 +282,10 @@ void on_dialog_used(TopDialogCategory category, DialogId dialog_id, int32 date); void update_used_hashtags(Td *td, const MessageContent *content); -void recognize_message_content_speech(Td *td, const MessageContent *content, FullMessageId full_message_id, +void recognize_message_content_speech(Td *td, const MessageContent *content, MessageFullId message_full_id, Promise &&promise); -void rate_message_content_speech_recognition(Td *td, const MessageContent *content, FullMessageId full_message_id, +void rate_message_content_speech_recognition(Td *td, const MessageContent *content, MessageFullId message_full_id, bool is_good, Promise &&promise); } // namespace td diff --git a/td/telegram/MessageDb.cpp b/td/telegram/MessageDb.cpp index 09ff99c4a..13c88b933 100644 --- a/td/telegram/MessageDb.cpp +++ b/td/telegram/MessageDb.cpp @@ -287,13 +287,13 @@ class MessageDbImpl final : public MessageDbSyncInterface { return Status::OK(); } - void add_message(FullMessageId full_message_id, ServerMessageId unique_message_id, DialogId sender_dialog_id, + void add_message(MessageFullId message_full_id, ServerMessageId unique_message_id, DialogId sender_dialog_id, int64 random_id, int32 ttl_expires_at, int32 index_mask, int64 search_id, string text, NotificationId notification_id, MessageId top_thread_message_id, BufferSlice data) final { - LOG(INFO) << "Add " << full_message_id << " to database"; - auto dialog_id = full_message_id.get_dialog_id(); - auto message_id = full_message_id.get_message_id(); - LOG_CHECK(dialog_id.is_valid()) << dialog_id << ' ' << message_id << ' ' << full_message_id; + LOG(INFO) << "Add " << message_full_id << " to database"; + auto dialog_id = message_full_id.get_dialog_id(); + auto message_id = message_full_id.get_message_id(); + LOG_CHECK(dialog_id.is_valid()) << dialog_id << ' ' << message_id << ' ' << message_full_id; CHECK(message_id.is_valid()); SCOPE_EXIT { add_message_stmt_.reset(); @@ -366,10 +366,10 @@ class MessageDbImpl final : public MessageDbSyncInterface { add_message_stmt_.step().ensure(); } - void add_scheduled_message(FullMessageId full_message_id, BufferSlice data) final { - LOG(INFO) << "Add " << full_message_id << " to database"; - auto dialog_id = full_message_id.get_dialog_id(); - auto message_id = full_message_id.get_message_id(); + void add_scheduled_message(MessageFullId message_full_id, BufferSlice data) final { + LOG(INFO) << "Add " << message_full_id << " to database"; + auto dialog_id = message_full_id.get_dialog_id(); + auto message_id = message_full_id.get_message_id(); CHECK(dialog_id.is_valid()); CHECK(message_id.is_valid_scheduled()); SCOPE_EXIT { @@ -389,10 +389,10 @@ class MessageDbImpl final : public MessageDbSyncInterface { add_scheduled_message_stmt_.step().ensure(); } - void delete_message(FullMessageId full_message_id) final { - LOG(INFO) << "Delete " << full_message_id << " from database"; - auto dialog_id = full_message_id.get_dialog_id(); - auto message_id = full_message_id.get_message_id(); + void delete_message(MessageFullId message_full_id) final { + LOG(INFO) << "Delete " << message_full_id << " from database"; + auto dialog_id = message_full_id.get_dialog_id(); + auto message_id = message_full_id.get_message_id(); CHECK(dialog_id.is_valid()); CHECK(message_id.is_valid() || message_id.is_valid_scheduled()); bool is_scheduled = message_id.is_scheduled(); @@ -439,9 +439,9 @@ class MessageDbImpl final : public MessageDbSyncInterface { delete_dialog_messages_by_sender_stmt_.step().ensure(); } - Result get_message(FullMessageId full_message_id) final { - auto dialog_id = full_message_id.get_dialog_id(); - auto message_id = full_message_id.get_message_id(); + Result get_message(MessageFullId message_full_id) final { + auto dialog_id = message_full_id.get_dialog_id(); + auto message_id = message_full_id.get_message_id(); CHECK(dialog_id.is_valid()); CHECK(message_id.is_valid() || message_id.is_valid_scheduled()); bool is_scheduled = message_id.is_scheduled(); @@ -988,20 +988,20 @@ class MessageDbAsync final : public MessageDbAsyncInterface { impl_ = create_actor_on_scheduler("MessageDbActor", scheduler_id, std::move(sync_db)); } - void add_message(FullMessageId full_message_id, ServerMessageId unique_message_id, DialogId sender_dialog_id, + void add_message(MessageFullId message_full_id, ServerMessageId unique_message_id, DialogId sender_dialog_id, int64 random_id, int32 ttl_expires_at, int32 index_mask, int64 search_id, string text, NotificationId notification_id, MessageId top_thread_message_id, BufferSlice data, Promise<> promise) final { - send_closure_later(impl_, &Impl::add_message, full_message_id, unique_message_id, sender_dialog_id, random_id, + send_closure_later(impl_, &Impl::add_message, message_full_id, unique_message_id, sender_dialog_id, random_id, ttl_expires_at, index_mask, search_id, std::move(text), notification_id, top_thread_message_id, std::move(data), std::move(promise)); } - void add_scheduled_message(FullMessageId full_message_id, BufferSlice data, Promise<> promise) final { - send_closure_later(impl_, &Impl::add_scheduled_message, full_message_id, std::move(data), std::move(promise)); + void add_scheduled_message(MessageFullId message_full_id, BufferSlice data, Promise<> promise) final { + send_closure_later(impl_, &Impl::add_scheduled_message, message_full_id, std::move(data), std::move(promise)); } - void delete_message(FullMessageId full_message_id, Promise<> promise) final { - send_closure_later(impl_, &Impl::delete_message, full_message_id, std::move(promise)); + void delete_message(MessageFullId message_full_id, Promise<> promise) final { + send_closure_later(impl_, &Impl::delete_message, message_full_id, std::move(promise)); } void delete_all_dialog_messages(DialogId dialog_id, MessageId from_message_id, Promise<> promise) final { send_closure_later(impl_, &Impl::delete_all_dialog_messages, dialog_id, from_message_id, std::move(promise)); @@ -1010,8 +1010,8 @@ class MessageDbAsync final : public MessageDbAsyncInterface { send_closure_later(impl_, &Impl::delete_dialog_messages_by_sender, dialog_id, sender_dialog_id, std::move(promise)); } - void get_message(FullMessageId full_message_id, Promise promise) final { - send_closure_later(impl_, &Impl::get_message, full_message_id, std::move(promise)); + void get_message(MessageFullId message_full_id, Promise promise) final { + send_closure_later(impl_, &Impl::get_message, message_full_id, std::move(promise)); } void get_message_by_unique_message_id(ServerMessageId unique_message_id, Promise promise) final { send_closure_later(impl_, &Impl::get_message_by_unique_message_id, unique_message_id, std::move(promise)); @@ -1068,29 +1068,29 @@ class MessageDbAsync final : public MessageDbAsyncInterface { public: explicit Impl(std::shared_ptr sync_db_safe) : sync_db_safe_(std::move(sync_db_safe)) { } - void add_message(FullMessageId full_message_id, ServerMessageId unique_message_id, DialogId sender_dialog_id, + void add_message(MessageFullId message_full_id, ServerMessageId unique_message_id, DialogId sender_dialog_id, int64 random_id, int32 ttl_expires_at, int32 index_mask, int64 search_id, string text, NotificationId notification_id, MessageId top_thread_message_id, BufferSlice data, Promise<> promise) { - add_write_query([this, full_message_id, unique_message_id, sender_dialog_id, random_id, ttl_expires_at, + add_write_query([this, message_full_id, unique_message_id, sender_dialog_id, random_id, ttl_expires_at, index_mask, search_id, text = std::move(text), notification_id, top_thread_message_id, data = std::move(data), promise = std::move(promise)](Unit) mutable { - sync_db_->add_message(full_message_id, unique_message_id, sender_dialog_id, random_id, ttl_expires_at, + sync_db_->add_message(message_full_id, unique_message_id, sender_dialog_id, random_id, ttl_expires_at, index_mask, search_id, std::move(text), notification_id, top_thread_message_id, std::move(data)); on_write_result(std::move(promise)); }); } - void add_scheduled_message(FullMessageId full_message_id, BufferSlice data, Promise<> promise) { - add_write_query([this, full_message_id, promise = std::move(promise), data = std::move(data)](Unit) mutable { - sync_db_->add_scheduled_message(full_message_id, std::move(data)); + void add_scheduled_message(MessageFullId message_full_id, BufferSlice data, Promise<> promise) { + add_write_query([this, message_full_id, promise = std::move(promise), data = std::move(data)](Unit) mutable { + sync_db_->add_scheduled_message(message_full_id, std::move(data)); on_write_result(std::move(promise)); }); } - void delete_message(FullMessageId full_message_id, Promise<> promise) { - add_write_query([this, full_message_id, promise = std::move(promise)](Unit) mutable { - sync_db_->delete_message(full_message_id); + void delete_message(MessageFullId message_full_id, Promise<> promise) { + add_write_query([this, message_full_id, promise = std::move(promise)](Unit) mutable { + sync_db_->delete_message(message_full_id); on_write_result(std::move(promise)); }); } @@ -1112,9 +1112,9 @@ class MessageDbAsync final : public MessageDbAsyncInterface { promise.set_value(Unit()); } - void get_message(FullMessageId full_message_id, Promise promise) { + void get_message(MessageFullId message_full_id, Promise promise) { add_read_query(); - promise.set_result(sync_db_->get_message(full_message_id)); + promise.set_result(sync_db_->get_message(message_full_id)); } void get_message_by_unique_message_id(ServerMessageId unique_message_id, Promise promise) { add_read_query(); diff --git a/td/telegram/MessageDb.h b/td/telegram/MessageDb.h index 8360f39d6..ed8f809d2 100644 --- a/td/telegram/MessageDb.h +++ b/td/telegram/MessageDb.h @@ -7,7 +7,7 @@ #pragma once #include "td/telegram/DialogId.h" -#include "td/telegram/FullMessageId.h" +#include "td/telegram/MessageFullId.h" #include "td/telegram/MessageId.h" #include "td/telegram/MessageSearchFilter.h" #include "td/telegram/NotificationId.h" @@ -104,16 +104,16 @@ class MessageDbSyncInterface { MessageDbSyncInterface &operator=(const MessageDbSyncInterface &) = delete; virtual ~MessageDbSyncInterface() = default; - virtual void add_message(FullMessageId full_message_id, ServerMessageId unique_message_id, DialogId sender_dialog_id, + virtual void add_message(MessageFullId message_full_id, ServerMessageId unique_message_id, DialogId sender_dialog_id, int64 random_id, int32 ttl_expires_at, int32 index_mask, int64 search_id, string text, NotificationId notification_id, MessageId top_thread_message_id, BufferSlice data) = 0; - virtual void add_scheduled_message(FullMessageId full_message_id, BufferSlice data) = 0; + virtual void add_scheduled_message(MessageFullId message_full_id, BufferSlice data) = 0; - virtual void delete_message(FullMessageId full_message_id) = 0; + virtual void delete_message(MessageFullId message_full_id) = 0; virtual void delete_all_dialog_messages(DialogId dialog_id, MessageId from_message_id) = 0; virtual void delete_dialog_messages_by_sender(DialogId dialog_id, DialogId sender_dialog_id) = 0; - virtual Result get_message(FullMessageId full_message_id) = 0; + virtual Result get_message(MessageFullId message_full_id) = 0; virtual Result get_message_by_unique_message_id(ServerMessageId unique_message_id) = 0; virtual Result get_message_by_random_id(DialogId dialog_id, int64 random_id) = 0; virtual Result get_dialog_message_by_date(DialogId dialog_id, MessageId first_message_id, @@ -155,17 +155,17 @@ class MessageDbAsyncInterface { MessageDbAsyncInterface &operator=(const MessageDbAsyncInterface &) = delete; virtual ~MessageDbAsyncInterface() = default; - virtual void add_message(FullMessageId full_message_id, ServerMessageId unique_message_id, DialogId sender_dialog_id, + virtual void add_message(MessageFullId message_full_id, ServerMessageId unique_message_id, DialogId sender_dialog_id, int64 random_id, int32 ttl_expires_at, int32 index_mask, int64 search_id, string text, NotificationId notification_id, MessageId top_thread_message_id, BufferSlice data, Promise<> promise) = 0; - virtual void add_scheduled_message(FullMessageId full_message_id, BufferSlice data, Promise<> promise) = 0; + virtual void add_scheduled_message(MessageFullId message_full_id, BufferSlice data, Promise<> promise) = 0; - virtual void delete_message(FullMessageId full_message_id, Promise<> promise) = 0; + virtual void delete_message(MessageFullId message_full_id, Promise<> promise) = 0; virtual void delete_all_dialog_messages(DialogId dialog_id, MessageId from_message_id, Promise<> promise) = 0; virtual void delete_dialog_messages_by_sender(DialogId dialog_id, DialogId sender_dialog_id, Promise<> promise) = 0; - virtual void get_message(FullMessageId full_message_id, Promise promise) = 0; + virtual void get_message(MessageFullId message_full_id, Promise promise) = 0; virtual void get_message_by_unique_message_id(ServerMessageId unique_message_id, Promise promise) = 0; virtual void get_message_by_random_id(DialogId dialog_id, int64 random_id, diff --git a/td/telegram/FullMessageId.h b/td/telegram/MessageFullId.h similarity index 68% rename from td/telegram/FullMessageId.h rename to td/telegram/MessageFullId.h index 1b8aac936..3c4af3a42 100644 --- a/td/telegram/FullMessageId.h +++ b/td/telegram/MessageFullId.h @@ -16,23 +16,23 @@ namespace td { -struct FullMessageId { +struct MessageFullId { private: DialogId dialog_id; MessageId message_id; public: - FullMessageId() : dialog_id(), message_id() { + MessageFullId() : dialog_id(), message_id() { } - FullMessageId(DialogId dialog_id, MessageId message_id) : dialog_id(dialog_id), message_id(message_id) { + MessageFullId(DialogId dialog_id, MessageId message_id) : dialog_id(dialog_id), message_id(message_id) { } - bool operator==(const FullMessageId &other) const { + bool operator==(const MessageFullId &other) const { return dialog_id == other.dialog_id && message_id == other.message_id; } - bool operator!=(const FullMessageId &other) const { + bool operator!=(const MessageFullId &other) const { return !(*this == other); } @@ -44,7 +44,7 @@ struct FullMessageId { return message_id; } - static FullMessageId get_full_message_id(const tl_object_ptr &message_ptr, bool is_scheduled) { + static MessageFullId get_message_full_id(const tl_object_ptr &message_ptr, bool is_scheduled) { return {DialogId::get_message_dialog_id(message_ptr), MessageId::get_message_id(message_ptr, is_scheduled)}; } @@ -61,15 +61,15 @@ struct FullMessageId { } }; -struct FullMessageIdHash { - uint32 operator()(FullMessageId full_message_id) const { - return combine_hashes(DialogIdHash()(full_message_id.get_dialog_id()), - MessageIdHash()(full_message_id.get_message_id())); +struct MessageFullIdHash { + uint32 operator()(MessageFullId message_full_id) const { + return combine_hashes(DialogIdHash()(message_full_id.get_dialog_id()), + MessageIdHash()(message_full_id.get_message_id())); } }; -inline StringBuilder &operator<<(StringBuilder &string_builder, FullMessageId full_message_id) { - return string_builder << full_message_id.get_message_id() << " in " << full_message_id.get_dialog_id(); +inline StringBuilder &operator<<(StringBuilder &string_builder, MessageFullId message_full_id) { + return string_builder << message_full_id.get_message_id() << " in " << message_full_id.get_dialog_id(); } } // namespace td diff --git a/td/telegram/MessageReaction.cpp b/td/telegram/MessageReaction.cpp index a4eafe984..f31487b01 100644 --- a/td/telegram/MessageReaction.cpp +++ b/td/telegram/MessageReaction.cpp @@ -101,8 +101,8 @@ class SendReactionQuery final : public Td::ResultHandler { explicit SendReactionQuery(Promise &&promise) : promise_(std::move(promise)) { } - void send(FullMessageId full_message_id, vector reaction_types, bool is_big, bool add_to_recent) { - dialog_id_ = full_message_id.get_dialog_id(); + void send(MessageFullId message_full_id, vector reaction_types, bool is_big, bool add_to_recent) { + dialog_id_ = message_full_id.get_dialog_id(); auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read); if (input_peer == nullptr) { @@ -125,10 +125,10 @@ class SendReactionQuery final : public Td::ResultHandler { send_query(G()->net_query_creator().create( telegram_api::messages_sendReaction( flags, false /*ignored*/, false /*ignored*/, std::move(input_peer), - full_message_id.get_message_id().get_server_message_id().get(), + message_full_id.get_message_id().get_server_message_id().get(), transform(reaction_types, [](const ReactionType &reaction_type) { return reaction_type.get_input_reaction(); })), - {{dialog_id_}, {full_message_id}})); + {{dialog_id_}, {message_full_id}})); } void on_result(BufferSlice packet) final { @@ -163,9 +163,9 @@ class GetMessageReactionsListQuery final : public Td::ResultHandler { : promise_(std::move(promise)) { } - void send(FullMessageId full_message_id, ReactionType reaction_type, string offset, int32 limit) { - dialog_id_ = full_message_id.get_dialog_id(); - message_id_ = full_message_id.get_message_id(); + void send(MessageFullId message_full_id, ReactionType reaction_type, string offset, int32 limit) { + dialog_id_ = message_full_id.get_dialog_id(); + message_id_ = message_full_id.get_message_id(); reaction_type_ = std::move(reaction_type); offset_ = std::move(offset); @@ -186,7 +186,7 @@ class GetMessageReactionsListQuery final : public Td::ResultHandler { telegram_api::messages_getMessageReactionsList(flags, std::move(input_peer), message_id_.get_server_message_id().get(), reaction_type_.get_input_reaction(), offset_, limit), - {{full_message_id}})); + {{message_full_id}})); } void on_result(BufferSlice packet) final { @@ -871,20 +871,20 @@ void reload_message_reactions(Td *td, DialogId dialog_id, vector &&me td->create_handler()->send(dialog_id, std::move(message_ids)); } -void send_message_reaction(Td *td, FullMessageId full_message_id, vector reaction_types, bool is_big, +void send_message_reaction(Td *td, MessageFullId message_full_id, vector reaction_types, bool is_big, bool add_to_recent, Promise &&promise) { td->create_handler(std::move(promise)) - ->send(full_message_id, std::move(reaction_types), is_big, add_to_recent); + ->send(message_full_id, std::move(reaction_types), is_big, add_to_recent); } -void get_message_added_reactions(Td *td, FullMessageId full_message_id, ReactionType reaction_type, string offset, +void get_message_added_reactions(Td *td, MessageFullId message_full_id, ReactionType reaction_type, string offset, int32 limit, Promise> &&promise) { - if (!td->messages_manager_->have_message_force(full_message_id, "get_message_added_reactions")) { + if (!td->messages_manager_->have_message_force(message_full_id, "get_message_added_reactions")) { return promise.set_error(Status::Error(400, "Message not found")); } - auto message_id = full_message_id.get_message_id(); - if (full_message_id.get_dialog_id().get_type() == DialogType::SecretChat || !message_id.is_valid() || + auto message_id = message_full_id.get_message_id(); + if (message_full_id.get_dialog_id().get_type() == DialogType::SecretChat || !message_id.is_valid() || !message_id.is_server()) { return promise.set_value(td_api::make_object(0, Auto(), string())); } @@ -898,12 +898,12 @@ void get_message_added_reactions(Td *td, FullMessageId full_message_id, Reaction } td->create_handler(std::move(promise)) - ->send(full_message_id, std::move(reaction_type), std::move(offset), limit); + ->send(message_full_id, std::move(reaction_type), std::move(offset), limit); } -void report_message_reactions(Td *td, FullMessageId full_message_id, DialogId chooser_dialog_id, +void report_message_reactions(Td *td, MessageFullId message_full_id, DialogId chooser_dialog_id, Promise &&promise) { - auto dialog_id = full_message_id.get_dialog_id(); + auto dialog_id = message_full_id.get_dialog_id(); if (!td->messages_manager_->have_dialog_force(dialog_id, "send_callback_query")) { return promise.set_error(Status::Error(400, "Chat not found")); } @@ -914,10 +914,10 @@ void report_message_reactions(Td *td, FullMessageId full_message_id, DialogId ch return promise.set_error(Status::Error(400, "Reactions can't be reported in the chat")); } - if (!td->messages_manager_->have_message_force(full_message_id, "report_user_reactions")) { + if (!td->messages_manager_->have_message_force(message_full_id, "report_user_reactions")) { return promise.set_error(Status::Error(400, "Message not found")); } - auto message_id = full_message_id.get_message_id(); + auto message_id = message_full_id.get_message_id(); if (message_id.is_valid_scheduled()) { return promise.set_error(Status::Error(400, "Can't report reactions on scheduled messages")); } diff --git a/td/telegram/MessageReaction.h b/td/telegram/MessageReaction.h index d39d540b1..c453da040 100644 --- a/td/telegram/MessageReaction.h +++ b/td/telegram/MessageReaction.h @@ -8,7 +8,7 @@ #include "td/telegram/ChannelId.h" #include "td/telegram/DialogId.h" -#include "td/telegram/FullMessageId.h" +#include "td/telegram/MessageFullId.h" #include "td/telegram/MessageId.h" #include "td/telegram/MinChannel.h" #include "td/telegram/ReactionType.h" @@ -212,13 +212,13 @@ StringBuilder &operator<<(StringBuilder &string_builder, const unique_ptr &&message_ids); -void send_message_reaction(Td *td, FullMessageId full_message_id, vector reaction_types, bool is_big, +void send_message_reaction(Td *td, MessageFullId message_full_id, vector reaction_types, bool is_big, bool add_to_recent, Promise &&promise); -void get_message_added_reactions(Td *td, FullMessageId full_message_id, ReactionType reaction_type, string offset, +void get_message_added_reactions(Td *td, MessageFullId message_full_id, ReactionType reaction_type, string offset, int32 limit, Promise> &&promise); -void report_message_reactions(Td *td, FullMessageId full_message_id, DialogId chooser_dialog_id, +void report_message_reactions(Td *td, MessageFullId message_full_id, DialogId chooser_dialog_id, Promise &&promise); } // namespace td diff --git a/td/telegram/MessageReplyHeader.cpp b/td/telegram/MessageReplyHeader.cpp index e5919010d..fc368d020 100644 --- a/td/telegram/MessageReplyHeader.cpp +++ b/td/telegram/MessageReplyHeader.cpp @@ -6,7 +6,7 @@ // #include "td/telegram/MessageReplyHeader.h" -#include "td/telegram/FullMessageId.h" +#include "td/telegram/MessageFullId.h" #include "td/telegram/ScheduledServerMessageId.h" #include "td/telegram/ServerMessageId.h" #include "td/telegram/StoryId.h" @@ -40,13 +40,13 @@ MessageReplyHeader::MessageReplyHeader(tl_object_ptrreply_to_peer_id_); if (reply_to_peer_id != nullptr) { reply_in_dialog_id_ = DialogId(reply_to_peer_id); - LOG(ERROR) << "Receive reply to " << FullMessageId{reply_in_dialog_id_, reply_to_message_id_} << " in " - << FullMessageId{dialog_id, message_id}; + LOG(ERROR) << "Receive reply to " << MessageFullId{reply_in_dialog_id_, reply_to_message_id_} << " in " + << MessageFullId{dialog_id, message_id}; reply_to_message_id_ = MessageId(); reply_in_dialog_id_ = DialogId(); } } else { - LOG(ERROR) << "Receive reply to " << reply_to_message_id_ << " in " << FullMessageId{dialog_id, message_id}; + LOG(ERROR) << "Receive reply to " << reply_to_message_id_ << " in " << MessageFullId{dialog_id, message_id}; reply_to_message_id_ = MessageId(); } } else { diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 3dc8663f4..12434b050 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -1709,13 +1709,13 @@ class GetMessagesViewsQuery final : public Td::ResultHandler { td_->contacts_manager_->on_get_users(std::move(result->users_), "GetMessagesViewsQuery"); td_->contacts_manager_->on_get_chats(std::move(result->chats_), "GetMessagesViewsQuery"); for (size_t i = 0; i < message_ids_.size(); i++) { - FullMessageId full_message_id{dialog_id_, message_ids_[i]}; + MessageFullId message_full_id{dialog_id_, message_ids_[i]}; auto *info = interaction_infos[i].get(); auto flags = info->flags_; auto view_count = (flags & telegram_api::messageViews::VIEWS_MASK) != 0 ? info->views_ : 0; auto forward_count = (flags & telegram_api::messageViews::FORWARDS_MASK) != 0 ? info->forwards_ : 0; - td_->messages_manager_->on_update_message_interaction_info(full_message_id, view_count, forward_count, true, + td_->messages_manager_->on_update_message_interaction_info(message_full_id, view_count, forward_count, true, std::move(info->replies_)); } td_->messages_manager_->finish_get_message_views(dialog_id_, message_ids_); @@ -2673,9 +2673,9 @@ class GetMessagePublicForwardsQuery final : public Td::ResultHandler { : promise_(std::move(promise)) { } - void send(DcId dc_id, FullMessageId full_message_id, int32 offset_date, DialogId offset_dialog_id, + void send(DcId dc_id, MessageFullId message_full_id, int32 offset_date, DialogId offset_dialog_id, ServerMessageId offset_message_id, int32 limit) { - dialog_id_ = full_message_id.get_dialog_id(); + dialog_id_ = message_full_id.get_dialog_id(); limit_ = limit; auto input_peer = MessagesManager::get_input_peer_force(offset_dialog_id); @@ -2686,7 +2686,7 @@ class GetMessagePublicForwardsQuery final : public Td::ResultHandler { send_query(G()->net_query_creator().create( telegram_api::stats_getMessagePublicForwards( - std::move(input_channel), full_message_id.get_message_id().get_server_message_id().get(), offset_date, + std::move(input_channel), message_full_id.get_message_id().get_server_message_id().get(), offset_date, std::move(input_peer), offset_message_id.get(), limit), {}, dc_id)); } @@ -4009,8 +4009,8 @@ class SendBotRequestedPeerQuery final : public Td::ResultHandler { explicit SendBotRequestedPeerQuery(Promise &&promise) : promise_(std::move(promise)) { } - void send(FullMessageId full_message_id, int32 button_id, DialogId requested_dialog_id) { - auto dialog_id = full_message_id.get_dialog_id(); + void send(MessageFullId message_full_id, int32 button_id, DialogId requested_dialog_id) { + auto dialog_id = message_full_id.get_dialog_id(); auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); if (input_peer == nullptr) { return on_error(Status::Error(400, "Can't access the chat")); @@ -4022,7 +4022,7 @@ class SendBotRequestedPeerQuery final : public Td::ResultHandler { send_query(G()->net_query_creator().create( telegram_api::messages_sendBotRequestedPeer(std::move(input_peer), - full_message_id.get_message_id().get_server_message_id().get(), + message_full_id.get_message_id().get_server_message_id().get(), button_id, std::move(requested_peer)), {{dialog_id, MessageContentType::Text}})); } @@ -5917,7 +5917,7 @@ MessagesManager::~MessagesManager() { story_to_replied_media_timestamp_messages_, notification_group_id_to_dialog_id_, pending_get_channel_differences_, active_get_channel_differences_, get_channel_difference_to_log_event_id_, channel_get_difference_retry_timeouts_, is_channel_difference_finished_, expected_channel_pts_, expected_channel_max_message_id_, resolved_usernames_, - inaccessible_resolved_usernames_, dialog_bot_command_message_ids_, full_message_id_to_file_source_id_, + inaccessible_resolved_usernames_, dialog_bot_command_message_ids_, message_full_id_to_file_source_id_, last_outgoing_forwarded_message_date_, dialog_viewed_messages_, dialog_online_member_counts_, previous_repaired_read_inbox_max_message_id_, failed_to_load_dialogs_); } @@ -6464,18 +6464,18 @@ void MessagesManager::skip_old_pending_pts_update(tl_object_ptrget_id() == telegram_api::updateNewMessage::ID) { auto update_new_message = static_cast(update.get()); - auto full_message_id = FullMessageId::get_full_message_id(update_new_message->message_, false); - if (update_message_ids_.count(full_message_id) > 0) { + auto message_full_id = MessageFullId::get_message_full_id(update_new_message->message_, false); + if (update_message_ids_.count(message_full_id) > 0) { // apply the sent message anyway, even it could have been deleted or edited already - CHECK(full_message_id.get_dialog_id().get_type() == DialogType::User || - full_message_id.get_dialog_id().get_type() == DialogType::Chat); // checked in check_pts_update - delete_messages_from_updates({full_message_id.get_message_id()}, false); + CHECK(message_full_id.get_dialog_id().get_type() == DialogType::User || + message_full_id.get_dialog_id().get_type() == DialogType::Chat); // checked in check_pts_update + delete_messages_from_updates({message_full_id.get_message_id()}, false); - auto added_full_message_id = on_get_message(std::move(update_new_message->message_), true, false, false, + auto added_message_full_id = on_get_message(std::move(update_new_message->message_), true, false, false, "updateNewMessage with an awaited message"); - if (added_full_message_id != full_message_id) { - LOG(ERROR) << "Failed to add an awaited " << full_message_id << " from " << source; + if (added_message_full_id != message_full_id) { + LOG(ERROR) << "Failed to add an awaited " << message_full_id << " from " << source; } return; } @@ -6764,32 +6764,32 @@ void MessagesManager::on_update_channel_too_long(tl_object_ptr &&reactions, Promise &&promise) { TRY_STATUS_PROMISE(promise, G()->close_status()); auto new_reactions = MessageReactions::get_message_reactions(td_, std::move(reactions), td_->auth_manager_->is_bot()); - if (!have_message_force(full_message_id, "on_update_message_reactions")) { - auto dialog_id = full_message_id.get_dialog_id(); + if (!have_message_force(message_full_id, "on_update_message_reactions")) { + auto dialog_id = message_full_id.get_dialog_id(); if (!have_input_peer(dialog_id, AccessRights::Read)) { - LOG(INFO) << "Ignore updateMessageReaction in inaccessible " << full_message_id; + LOG(INFO) << "Ignore updateMessageReaction in inaccessible " << message_full_id; promise.set_value(Unit()); return; } @@ -6811,19 +6811,19 @@ void MessagesManager::on_update_message_reactions(FullMessageId full_message_id, return; } - update_message_interaction_info(full_message_id, -1, -1, false, nullptr, true, std::move(new_reactions)); + update_message_interaction_info(message_full_id, -1, -1, false, nullptr, true, std::move(new_reactions)); promise.set_value(Unit()); } -void MessagesManager::update_message_reactions(FullMessageId full_message_id, +void MessagesManager::update_message_reactions(MessageFullId message_full_id, unique_ptr &&reactions) { - update_message_interaction_info(full_message_id, -1, -1, false, nullptr, true, std::move(reactions)); + update_message_interaction_info(message_full_id, -1, -1, false, nullptr, true, std::move(reactions)); } void MessagesManager::on_get_message_reaction_list( - FullMessageId full_message_id, const ReactionType &reaction_type, + MessageFullId message_full_id, const ReactionType &reaction_type, FlatHashMap, ReactionTypeHash> reaction_types, int32 total_count) { - const Message *m = get_message_force(full_message_id, "on_get_message_reaction_list"); + const Message *m = get_message_force(message_full_id, "on_get_message_reaction_list"); if (m == nullptr || m->reactions == nullptr) { return; } @@ -6834,24 +6834,24 @@ void MessagesManager::on_get_message_reaction_list( return; } - LOG(INFO) << "Need reload reactions in " << full_message_id << " for consistency"; + LOG(INFO) << "Need reload reactions in " << message_full_id << " for consistency"; - auto it = pending_reactions_.find(full_message_id); + auto it = pending_reactions_.find(message_full_id); if (it != pending_reactions_.end()) { it->second.was_updated = true; } else { - queue_message_reactions_reload(full_message_id); + queue_message_reactions_reload(message_full_id); } } -void MessagesManager::on_update_message_interaction_info(FullMessageId full_message_id, int32 view_count, +void MessagesManager::on_update_message_interaction_info(MessageFullId message_full_id, int32 view_count, int32 forward_count, bool has_reply_info, tl_object_ptr &&reply_info) { if (view_count < 0 || forward_count < 0) { - LOG(ERROR) << "Receive " << view_count << "/" << forward_count << " interaction counters for " << full_message_id; + LOG(ERROR) << "Receive " << view_count << "/" << forward_count << " interaction counters for " << message_full_id; return; } - update_message_interaction_info(full_message_id, view_count, forward_count, has_reply_info, std::move(reply_info), + update_message_interaction_info(message_full_id, view_count, forward_count, has_reply_info, std::move(reply_info), false, nullptr); } @@ -6899,7 +6899,7 @@ void MessagesManager::on_pending_message_views_timeout(DialogId dialog_id) { pending_message_views_.erase(it); } -void MessagesManager::update_message_interaction_info(FullMessageId full_message_id, int32 view_count, +void MessagesManager::update_message_interaction_info(MessageFullId message_full_id, int32 view_count, int32 forward_count, bool has_reply_info, tl_object_ptr &&reply_info, bool has_reactions, unique_ptr &&reactions) { @@ -6907,15 +6907,15 @@ void MessagesManager::update_message_interaction_info(FullMessageId full_message return; } - auto dialog_id = full_message_id.get_dialog_id(); + auto dialog_id = message_full_id.get_dialog_id(); Dialog *d = get_dialog_force(dialog_id, "update_message_interaction_info"); if (d == nullptr) { return; } - auto message_id = full_message_id.get_message_id(); + auto message_id = message_full_id.get_message_id(); Message *m = get_message_force(d, message_id, "update_message_interaction_info"); if (m == nullptr) { - LOG(INFO) << "Ignore message interaction info about unknown " << full_message_id; + LOG(INFO) << "Ignore message interaction info about unknown " << message_full_id; if (!message_id.is_scheduled() && d->last_new_message_id.is_valid() && message_id > d->last_new_message_id && dialog_id.get_type() == DialogType::Channel) { get_channel_difference(dialog_id, d->pts, 0, message_id, true, "update_message_interaction_info"); @@ -7132,16 +7132,16 @@ bool MessagesManager::update_message_interaction_info(Dialog *d, Message *m, int } } } - FullMessageId full_message_id{dialog_id, m->message_id}; + MessageFullId message_full_id{dialog_id, m->message_id}; if (has_reactions) { - auto it = pending_reactions_.find(full_message_id); + auto it = pending_reactions_.find(message_full_id); if (it != pending_reactions_.end()) { - LOG(INFO) << "Ignore reactions for " << full_message_id << ", because they are being changed"; + LOG(INFO) << "Ignore reactions for " << message_full_id << ", because they are being changed"; has_reactions = false; it->second.was_updated = true; } - if (has_reactions && pending_read_reactions_.count(full_message_id) > 0) { - LOG(INFO) << "Ignore reactions for " << full_message_id << ", because they are being read"; + if (has_reactions && pending_read_reactions_.count(message_full_id) > 0) { + LOG(INFO) << "Ignore reactions for " << message_full_id << ", because they are being read"; has_reactions = false; } } @@ -7160,7 +7160,7 @@ bool MessagesManager::update_message_interaction_info(Dialog *d, Message *m, int m->reactions->chosen_reaction_order_ != reactions->chosen_reaction_order_; if (view_count > m->view_count || forward_count > m->forward_count || need_update_reply_info || need_update_reactions || need_update_unread_reactions || need_update_chosen_reaction_order) { - LOG(DEBUG) << "Update interaction info of " << full_message_id << " from " << m->view_count << '/' + LOG(DEBUG) << "Update interaction info of " << message_full_id << " from " << m->view_count << '/' << m->forward_count << '/' << m->reply_info << '/' << m->reactions << " to " << view_count << '/' << forward_count << '/' << reply_info << '/' << reactions << ", need_update_reply_info = " << need_update_reply_info @@ -7179,7 +7179,7 @@ bool MessagesManager::update_message_interaction_info(Dialog *d, Message *m, int if (need_update_reply_info) { if (m->reply_info.channel_id_ != reply_info.channel_id_) { if (m->reply_info.channel_id_.is_valid() && reply_info.channel_id_.is_valid() && m->message_id.is_server()) { - LOG(ERROR) << "Reply info of " << full_message_id << " changed from " << m->reply_info << " to " << reply_info + LOG(ERROR) << "Reply info of " << message_full_id << " changed from " << m->reply_info << " to " << reply_info << " from " << source; } } @@ -7250,22 +7250,22 @@ bool MessagesManager::update_message_interaction_info(Dialog *d, Message *m, int return false; } -void MessagesManager::on_update_live_location_viewed(FullMessageId full_message_id) { - LOG(DEBUG) << "Live location was viewed in " << full_message_id; +void MessagesManager::on_update_live_location_viewed(MessageFullId message_full_id) { + LOG(DEBUG) << "Live location was viewed in " << message_full_id; if (!are_active_live_location_messages_loaded_) { - get_active_live_location_messages(PromiseCreator::lambda([actor_id = actor_id(this), full_message_id](Unit result) { - send_closure(actor_id, &MessagesManager::on_update_live_location_viewed, full_message_id); + get_active_live_location_messages(PromiseCreator::lambda([actor_id = actor_id(this), message_full_id](Unit result) { + send_closure(actor_id, &MessagesManager::on_update_live_location_viewed, message_full_id); })); return; } auto active_live_location_message_ids = get_active_live_location_messages(Auto()); - if (!td::contains(active_live_location_message_ids, full_message_id)) { - LOG(DEBUG) << "Can't find " << full_message_id << " in " << active_live_location_message_ids; + if (!td::contains(active_live_location_message_ids, message_full_id)) { + LOG(DEBUG) << "Can't find " << message_full_id << " in " << active_live_location_message_ids; return; } - send_update_message_live_location_viewed(full_message_id); + send_update_message_live_location_viewed(message_full_id); } void MessagesManager::on_update_some_live_location_viewed(Promise &&promise) { @@ -7280,25 +7280,25 @@ void MessagesManager::on_update_some_live_location_viewed(Promise &&promis // update all live locations, because it is unknown, which exactly was viewed auto active_live_location_message_ids = get_active_live_location_messages(Auto()); - for (const auto &full_message_id : active_live_location_message_ids) { - send_update_message_live_location_viewed(full_message_id); + for (const auto &message_full_id : active_live_location_message_ids) { + send_update_message_live_location_viewed(message_full_id); } promise.set_value(Unit()); } void MessagesManager::on_update_message_extended_media( - FullMessageId full_message_id, telegram_api::object_ptr extended_media) { - auto dialog_id = full_message_id.get_dialog_id(); + MessageFullId message_full_id, telegram_api::object_ptr extended_media) { + auto dialog_id = message_full_id.get_dialog_id(); Dialog *d = get_dialog_force(dialog_id, "on_update_message_extended_media"); if (d == nullptr) { LOG(INFO) << "Ignore update of message extended media in unknown " << dialog_id; return; } - auto m = get_message_force(d, full_message_id.get_message_id(), "on_update_message_extended_media"); + auto m = get_message_force(d, message_full_id.get_message_id(), "on_update_message_extended_media"); if (m == nullptr) { - LOG(INFO) << "Ignore update of message extended media in unknown " << full_message_id; + LOG(INFO) << "Ignore update of message extended media in unknown " << message_full_id; return; } @@ -7306,7 +7306,7 @@ void MessagesManager::on_update_message_extended_media( auto content_type = content->get_type(); if (content_type != MessageContentType::Invoice) { if (content_type != MessageContentType::Unsupported) { - LOG(ERROR) << "Receive updateMessageExtendedMedia for " << full_message_id << " of type " << content_type; + LOG(ERROR) << "Receive updateMessageExtendedMedia for " << message_full_id << " of type " << content_type; } return; } @@ -7331,10 +7331,10 @@ bool MessagesManager::need_skip_bot_commands(DialogId dialog_id, const Message * return (d->is_has_bots_inited && !d->has_bots) || is_broadcast_channel(dialog_id); } -void MessagesManager::on_external_update_message_content(FullMessageId full_message_id) { - Dialog *d = get_dialog(full_message_id.get_dialog_id()); +void MessagesManager::on_external_update_message_content(MessageFullId message_full_id) { + Dialog *d = get_dialog(message_full_id.get_dialog_id()); CHECK(d != nullptr); - Message *m = get_message(d, full_message_id.get_message_id()); + Message *m = get_message(d, message_full_id.get_message_id()); CHECK(m != nullptr); send_update_message_content(d, m, true, "on_external_update_message_content"); // must not call on_message_changed, because the message itself wasn't changed @@ -7344,10 +7344,10 @@ void MessagesManager::on_external_update_message_content(FullMessageId full_mess on_message_notification_changed(d, m, "on_external_update_message_content"); } -void MessagesManager::on_update_message_content(FullMessageId full_message_id) { - Dialog *d = get_dialog(full_message_id.get_dialog_id()); +void MessagesManager::on_update_message_content(MessageFullId message_full_id) { + Dialog *d = get_dialog(message_full_id.get_dialog_id()); CHECK(d != nullptr); - Message *m = get_message(d, full_message_id.get_message_id()); + Message *m = get_message(d, message_full_id.get_message_id()); CHECK(m != nullptr); send_update_message_content(d, m, true, "on_update_message_content"); on_message_changed(d, m, true, "on_update_message_content"); @@ -7604,10 +7604,10 @@ void MessagesManager::on_dialog_action(DialogId dialog_id, MessageId top_thread_ auto clicking_info = action.get_clicking_animated_emoji_action_info(); if (!clicking_info.data.empty()) { if (date > G()->unix_time() - 10 && dialog_type == DialogType::User && dialog_id == typing_dialog_id) { - FullMessageId full_message_id{dialog_id, MessageId(ServerMessageId(clicking_info.message_id))}; - auto *m = get_message_force(full_message_id, "on_dialog_action"); + MessageFullId message_full_id{dialog_id, MessageId(ServerMessageId(clicking_info.message_id))}; + auto *m = get_message_force(message_full_id, "on_dialog_action"); if (m != nullptr) { - on_message_content_animated_emoji_clicked(m->content.get(), full_message_id, td_, + on_message_content_animated_emoji_clicked(m->content.get(), message_full_id, td_, std::move(clicking_info.emoji), std::move(clicking_info.data)); } } @@ -7799,13 +7799,13 @@ void MessagesManager::add_pending_channel_update(DialogId dialog_id, tl_object_p if (update->get_id() == telegram_api::updateNewChannelMessage::ID) { auto update_new_channel_message = static_cast(update.get()); auto message_id = MessageId::get_message_id(update_new_channel_message->message_, false); - FullMessageId full_message_id(dialog_id, message_id); - if (update_message_ids_.count(full_message_id) > 0) { + MessageFullId message_full_id(dialog_id, message_id); + if (update_message_ids_.count(message_full_id) > 0) { // apply sent channel message - auto added_full_message_id = on_get_message(std::move(update_new_channel_message->message_), true, true, + auto added_message_full_id = on_get_message(std::move(update_new_channel_message->message_), true, true, false, "updateNewChannelMessage with an awaited message"); - if (added_full_message_id != full_message_id) { - LOG(ERROR) << "Failed to add an awaited " << full_message_id << " from " << source; + if (added_message_full_id != message_full_id) { + LOG(ERROR) << "Failed to add an awaited " << message_full_id << " from " << source; } promise.set_value(Unit()); return; @@ -7917,9 +7917,9 @@ void MessagesManager::process_pts_update(tl_object_ptr &&u auto update = move_tl_object_as(update_ptr); LOG(INFO) << "Process updateEditMessage"; bool had_message = - have_message_force(FullMessageId::get_full_message_id(update->message_, false), "updateEditMessage"); - auto full_message_id = on_get_message(std::move(update->message_), false, false, false, "updateEditMessage"); - on_message_edited(full_message_id, update->pts_, had_message); + have_message_force(MessageFullId::get_message_full_id(update->message_, false), "updateEditMessage"); + auto message_full_id = on_get_message(std::move(update->message_), false, false, false, "updateEditMessage"); + on_message_edited(message_full_id, update->pts_, had_message); break; } case telegram_api::updateDeleteMessages::ID: { @@ -8008,13 +8008,13 @@ bool MessagesManager::process_channel_update(tl_object_ptr auto update = move_tl_object_as(update_ptr); LOG(INFO) << "Process updateEditChannelMessage"; bool had_message = - have_message_force(FullMessageId::get_full_message_id(update->message_, false), "updateEditChannelMessage"); - auto full_message_id = + have_message_force(MessageFullId::get_message_full_id(update->message_, false), "updateEditChannelMessage"); + auto message_full_id = on_get_message(std::move(update->message_), false, true, false, "updateEditChannelMessage"); - if (full_message_id == FullMessageId()) { + if (message_full_id == MessageFullId()) { return false; } - on_message_edited(full_message_id, update->pts_, had_message); + on_message_edited(message_full_id, update->pts_, had_message); break; } case telegram_api::updatePinnedChannelMessages::ID: { @@ -8040,14 +8040,14 @@ bool MessagesManager::process_channel_update(tl_object_ptr return true; } -void MessagesManager::on_message_edited(FullMessageId full_message_id, int32 pts, bool had_message) { - if (full_message_id == FullMessageId()) { +void MessagesManager::on_message_edited(MessageFullId message_full_id, int32 pts, bool had_message) { + if (message_full_id == MessageFullId()) { return; } - auto dialog_id = full_message_id.get_dialog_id(); + auto dialog_id = message_full_id.get_dialog_id(); Dialog *d = get_dialog(dialog_id); - Message *m = get_message(d, full_message_id.get_message_id()); + Message *m = get_message(d, message_full_id.get_message_id()); CHECK(m != nullptr); m->last_edit_pts = pts; d->last_edited_message_id = m->message_id; @@ -8535,10 +8535,10 @@ bool MessagesManager::need_poll_message_reactions(const Dialog *d, const Message return true; } -void MessagesManager::queue_message_reactions_reload(FullMessageId full_message_id) { - auto dialog_id = full_message_id.get_dialog_id(); +void MessagesManager::queue_message_reactions_reload(MessageFullId message_full_id) { + auto dialog_id = message_full_id.get_dialog_id(); CHECK(dialog_id.is_valid()); - auto message_id = full_message_id.get_message_id(); + auto message_id = message_full_id.get_message_id(); CHECK(message_id.is_valid()); being_reloaded_reactions_[dialog_id].message_ids.insert(message_id); try_reload_message_reactions(dialog_id, false); @@ -8980,8 +8980,8 @@ void MessagesManager::fix_dialog_action_bar(const Dialog *d, DialogActionBar *ac action_bar->fix(td_, d->dialog_id, d->is_blocked, d->folder_id); } -Result MessagesManager::get_login_button_url(FullMessageId full_message_id, int64 button_id) { - Dialog *d = get_dialog_force(full_message_id.get_dialog_id(), "get_login_button_url"); +Result MessagesManager::get_login_button_url(MessageFullId message_full_id, int64 button_id) { + Dialog *d = get_dialog_force(message_full_id.get_dialog_id(), "get_login_button_url"); if (d == nullptr) { return Status::Error(400, "Chat not found"); } @@ -8989,7 +8989,7 @@ Result MessagesManager::get_login_button_url(FullMessageId full_message_ return Status::Error(400, "Can't access the chat"); } - auto m = get_message_force(d, full_message_id.get_message_id(), "get_login_button_url"); + auto m = get_message_force(d, message_full_id.get_message_id(), "get_login_button_url"); if (m == nullptr) { return Status::Error(400, "Message not found"); } @@ -9072,12 +9072,12 @@ void MessagesManager::on_upload_media(FileId file_id, tl_object_ptrsecond.first; + auto message_full_id = it->second.first; auto thumbnail_file_id = it->second.second; being_uploaded_files_.erase(it); - Message *m = get_message(full_message_id); + Message *m = get_message(message_full_id); if (m == nullptr) { // message has already been deleted by the user or sent to inaccessible channel, do not need to send or edit it // file upload should be already canceled in cancel_send_message_query, it shouldn't happen @@ -9086,13 +9086,13 @@ void MessagesManager::on_upload_media(FileId file_id, tl_object_ptrmessage_id.is_any_server(); - auto dialog_id = full_message_id.get_dialog_id(); + auto dialog_id = message_full_id.get_dialog_id(); auto can_send_status = can_send_message(dialog_id); if (!is_edit && can_send_status.is_error()) { // user has left the chat during upload of the file or lost their privileges LOG(INFO) << "Can't send a message to " << dialog_id << ": " << can_send_status; - fail_send_message(full_message_id, std::move(can_send_status)); + fail_send_message(message_full_id, std::move(can_send_status)); return; } @@ -9105,7 +9105,7 @@ void MessagesManager::on_upload_media(FileId file_id, tl_object_ptrfile_manager_->upload(thumbnail_file_id, upload_thumbnail_callback_, 32, m->message_id.get()); @@ -9117,7 +9117,7 @@ void MessagesManager::on_upload_media(FileId file_id, tl_object_ptrsecond.first; + auto message_full_id = it->second.first; being_uploaded_files_.erase(it); - bool is_edit = full_message_id.get_message_id().is_any_server(); + bool is_edit = message_full_id.get_message_id().is_any_server(); if (is_edit) { - fail_edit_message_media(full_message_id, std::move(status)); + fail_edit_message_media(message_full_id, std::move(status)); } else { - fail_send_message(full_message_id, std::move(status)); + fail_send_message(message_full_id, std::move(status)); } } @@ -9225,13 +9225,13 @@ void MessagesManager::on_load_secret_thumbnail(FileId thumbnail_file_id, BufferS return; } - auto full_message_id = it->second.full_message_id; + auto message_full_id = it->second.message_full_id; auto file_id = it->second.file_id; auto input_file = std::move(it->second.input_file); being_loaded_secret_thumbnails_.erase(it); - Message *m = get_message(full_message_id); + Message *m = get_message(message_full_id); if (m == nullptr) { // message has already been deleted by the user, do not need to send it // cancel file upload of the main file to allow next upload with the same file to succeed @@ -9245,13 +9245,13 @@ void MessagesManager::on_load_secret_thumbnail(FileId thumbnail_file_id, BufferS delete_message_content_thumbnail(m->content.get(), td_); } - auto dialog_id = full_message_id.get_dialog_id(); + auto dialog_id = message_full_id.get_dialog_id(); auto can_send_status = can_send_message(dialog_id); if (can_send_status.is_error()) { // secret chat was closed during load of the file LOG(INFO) << "Can't send a message to " << dialog_id << ": " << can_send_status; - fail_send_message(full_message_id, std::move(can_send_status)); + fail_send_message(message_full_id, std::move(can_send_status)); return; } @@ -9273,13 +9273,13 @@ void MessagesManager::on_upload_thumbnail(FileId thumbnail_file_id, return; } - auto full_message_id = it->second.full_message_id; + auto message_full_id = it->second.message_full_id; auto file_id = it->second.file_id; auto input_file = std::move(it->second.input_file); being_uploaded_thumbnails_.erase(it); - Message *m = get_message(full_message_id); + Message *m = get_message(message_full_id); if (m == nullptr) { // message has already been deleted by the user or sent to inaccessible channel, do not need to send or edit it // thumbnail file upload should be already canceled in cancel_send_message_query @@ -9293,13 +9293,13 @@ void MessagesManager::on_upload_thumbnail(FileId thumbnail_file_id, delete_message_content_thumbnail(is_edit ? m->edited_content.get() : m->content.get(), td_); } - auto dialog_id = full_message_id.get_dialog_id(); + auto dialog_id = message_full_id.get_dialog_id(); auto can_send_status = can_send_message(dialog_id); if (!is_edit && can_send_status.is_error()) { // user has left the chat during upload of the thumbnail or lost their privileges LOG(INFO) << "Can't send a message to " << dialog_id << ": " << can_send_status; - fail_send_message(full_message_id, std::move(can_send_status)); + fail_send_message(message_full_id, std::move(can_send_status)); return; } @@ -9562,14 +9562,14 @@ void MessagesManager::after_get_difference() { send_update_unread_chat_count(*list, DialogId(), true, "after_get_difference"); } - vector update_message_ids_to_delete; + vector update_message_ids_to_delete; for (auto &it : update_message_ids_) { // there can be unhandled updateMessageId updates after getDifference even for ordinary chats, // because despite updates coming during getDifference have already been applied, // some of them could be postponed because of PTS gap - auto full_message_id = it.first; - auto dialog_id = full_message_id.get_dialog_id(); - auto message_id = full_message_id.get_message_id(); + auto message_full_id = it.first; + auto dialog_id = message_full_id.get_dialog_id(); + auto message_id = message_full_id.get_message_id(); auto old_message_id = it.second; CHECK(message_id.is_valid()); CHECK(message_id.is_server()); @@ -9593,7 +9593,7 @@ void MessagesManager::after_get_difference() { if (!have_input_peer(dialog_id, AccessRights::Read) || (d != nullptr && message_id <= td::max(d->last_clear_history_message_id, d->max_unavailable_message_id))) { - update_message_ids_to_delete.push_back(full_message_id); + update_message_ids_to_delete.push_back(message_full_id); } break; } @@ -9601,15 +9601,15 @@ void MessagesManager::after_get_difference() { const Dialog *d = get_dialog(dialog_id); CHECK(d != nullptr); if (dialog_id.get_type() == DialogType::Channel || message_id <= d->last_new_message_id) { - LOG(ERROR) << "Receive updateMessageId from " << old_message_id << " to " << full_message_id + LOG(ERROR) << "Receive updateMessageId from " << old_message_id << " to " << message_full_id << " but not receive corresponding message, last_new_message_id = " << d->last_new_message_id; } if (message_id <= d->last_new_message_id) { get_message_from_server( - full_message_id, - PromiseCreator::lambda([actor_id = actor_id(this), full_message_id, old_message_id](Result result) { + message_full_id, + PromiseCreator::lambda([actor_id = actor_id(this), message_full_id, old_message_id](Result result) { send_closure(actor_id, &MessagesManager::on_restore_missing_message_after_get_difference, - full_message_id, old_message_id, std::move(result)); + message_full_id, old_message_id, std::move(result)); }), "get missing"); } else if (dialog_id.get_type() == DialogType::Channel) { @@ -9625,8 +9625,8 @@ void MessagesManager::after_get_difference() { break; } } - for (const auto &full_message_id : update_message_ids_to_delete) { - update_message_ids_.erase(full_message_id); + for (const auto &message_full_id : update_message_ids_to_delete) { + update_message_ids_.erase(message_full_id); } if (!td_->auth_manager_->is_bot()) { @@ -9646,21 +9646,21 @@ void MessagesManager::after_get_difference() { } } -void MessagesManager::on_restore_missing_message_after_get_difference(FullMessageId full_message_id, +void MessagesManager::on_restore_missing_message_after_get_difference(MessageFullId message_full_id, MessageId old_message_id, Result result) { if (result.is_error()) { - LOG(WARNING) << "Failed to get missing " << full_message_id << " for " << old_message_id << ": " << result.error(); + LOG(WARNING) << "Failed to get missing " << message_full_id << " for " << old_message_id << ": " << result.error(); } else { - LOG(WARNING) << "Successfully get missing " << full_message_id << " for " << old_message_id; + LOG(WARNING) << "Successfully get missing " << message_full_id << " for " << old_message_id; - bool have_message = have_message_force(full_message_id, "on_restore_missing_message_after_get_difference"); - if (!have_message && update_message_ids_.count(full_message_id)) { - LOG(ERROR) << "Receive messageEmpty instead of missing " << full_message_id << " for " << old_message_id; + bool have_message = have_message_force(message_full_id, "on_restore_missing_message_after_get_difference"); + if (!have_message && update_message_ids_.count(message_full_id)) { + LOG(ERROR) << "Receive messageEmpty instead of missing " << message_full_id << " for " << old_message_id; - delete_dialog_messages(full_message_id.get_dialog_id(), {old_message_id}, false, + delete_dialog_messages(message_full_id.get_dialog_id(), {old_message_id}, false, "on_restore_missing_message_after_get_difference"); - update_message_ids_.erase(full_message_id); + update_message_ids_.erase(message_full_id); } } } @@ -9887,8 +9887,8 @@ void MessagesManager::on_get_history(DialogId dialog_id, MessageId from_message_ continue; } - auto full_message_id = on_get_message(std::move(message), false, is_channel_message, false, "get history"); - auto message_id = full_message_id.get_message_id(); + auto message_full_id = on_get_message(std::move(message), false, is_channel_message, false, "get history"); + auto message_id = message_full_id.get_message_id(); if (message_id.is_valid()) { CHECK(message_id == expected_message_id); if (have_next) { @@ -10090,15 +10090,15 @@ void MessagesManager::on_get_message_search_result_calendar( int32 received_message_count = 0; for (auto &message : messages) { - auto new_full_message_id = on_get_message(std::move(message), false, dialog_id.get_type() == DialogType::Channel, + auto new_message_full_id = on_get_message(std::move(message), false, dialog_id.get_type() == DialogType::Channel, false, "on_get_message_search_result_calendar"); - if (new_full_message_id == FullMessageId()) { + if (new_message_full_id == MessageFullId()) { total_count--; continue; } - if (new_full_message_id.get_dialog_id() != dialog_id) { - LOG(ERROR) << "Receive " << new_full_message_id << " instead of a message in " << dialog_id; + if (new_message_full_id.get_dialog_id() != dialog_id) { + LOG(ERROR) << "Receive " << new_message_full_id << " instead of a message in " << dialog_id; total_count--; continue; } @@ -10165,7 +10165,7 @@ void MessagesManager::on_get_dialog_messages_search_result( first_added_message_id = MessageId::min(); } - auto &result = it->second.full_message_ids; + auto &result = it->second.message_full_ids; CHECK(result.empty()); int32 added_message_count = 0; MessageId next_offset_message_id; @@ -10174,15 +10174,15 @@ void MessagesManager::on_get_dialog_messages_search_result( if (message_id.is_valid() && (!next_offset_message_id.is_valid() || message_id < next_offset_message_id)) { next_offset_message_id = message_id; } - auto new_full_message_id = on_get_message(std::move(message), false, false, false, "search call messages"); - if (new_full_message_id == FullMessageId()) { + auto new_message_full_id = on_get_message(std::move(message), false, false, false, "search call messages"); + if (new_message_full_id == MessageFullId()) { continue; } - result.push_back(new_full_message_id); + result.push_back(new_message_full_id); added_message_count++; - CHECK(message_id == new_full_message_id.get_message_id()); + CHECK(message_id == new_message_full_id.get_message_id()); CHECK(message_id.is_valid()); if (message_id < first_added_message_id || !first_added_message_id.is_valid()) { first_added_message_id = message_id; @@ -10247,24 +10247,24 @@ void MessagesManager::on_get_dialog_messages_search_result( if (message_id.is_valid() && (!next_from_message_id.is_valid() || message_id < next_from_message_id)) { next_from_message_id = message_id; } - auto new_full_message_id = on_get_message(std::move(message), false, dialog_id.get_type() == DialogType::Channel, + auto new_message_full_id = on_get_message(std::move(message), false, dialog_id.get_type() == DialogType::Channel, false, "on_get_dialog_messages_search_result"); - if (new_full_message_id == FullMessageId()) { + if (new_message_full_id == MessageFullId()) { total_count--; continue; } - if (new_full_message_id.get_dialog_id() != dialog_id) { + if (new_message_full_id.get_dialog_id() != dialog_id) { if (!can_be_in_different_dialog) { - LOG(ERROR) << "Receive " << new_full_message_id << " instead of a message in " << dialog_id; + LOG(ERROR) << "Receive " << new_message_full_id << " instead of a message in " << dialog_id; total_count--; continue; } else { if (!real_dialog_id.is_valid()) { - real_dialog_id = new_full_message_id.get_dialog_id(); + real_dialog_id = new_message_full_id.get_dialog_id(); found_dialog_messages_dialog_id_[random_id] = real_dialog_id; - } else if (new_full_message_id.get_dialog_id() != real_dialog_id) { - LOG(ERROR) << "Receive " << new_full_message_id << " instead of a message in " << real_dialog_id << " or " + } else if (new_message_full_id.get_dialog_id() != real_dialog_id) { + LOG(ERROR) << "Receive " << new_message_full_id << " instead of a message in " << real_dialog_id << " or " << dialog_id; total_count--; continue; @@ -10272,7 +10272,7 @@ void MessagesManager::on_get_dialog_messages_search_result( } } - CHECK(message_id == new_full_message_id.get_message_id()); + CHECK(message_id == new_message_full_id.get_message_id()); if (filter == MessageSearchFilter::UnreadMention && message_id <= d->last_read_all_mentions_message_id && !real_dialog_id.is_valid()) { total_count--; @@ -10280,11 +10280,11 @@ void MessagesManager::on_get_dialog_messages_search_result( } if (filter != MessageSearchFilter::Empty) { - const Message *m = get_message(new_full_message_id); + const Message *m = get_message(new_message_full_id); CHECK(m != nullptr); - auto index_mask = get_message_index_mask(new_full_message_id.get_dialog_id(), m); + auto index_mask = get_message_index_mask(new_message_full_id.get_dialog_id(), m); if ((message_search_filter_index_mask(filter) & index_mask) == 0) { - LOG(INFO) << "Skip " << new_full_message_id << " of unexpected type"; + LOG(INFO) << "Skip " << new_message_full_id << " of unexpected type"; total_count--; continue; } @@ -10404,7 +10404,7 @@ void MessagesManager::on_get_messages_search_result(const string &query, int32 o auto it = found_messages_.find(random_id); CHECK(it != found_messages_.end()); - auto &result = it->second.full_message_ids; + auto &result = it->second.message_full_ids; CHECK(result.empty()); int32 last_message_date = 0; MessageId last_message_id; @@ -10419,11 +10419,11 @@ void MessagesManager::on_get_messages_search_result(const string &query, int32 o last_dialog_id = dialog_id; } - auto new_full_message_id = on_get_message(std::move(message), false, dialog_id.get_type() == DialogType::Channel, + auto new_message_full_id = on_get_message(std::move(message), false, dialog_id.get_type() == DialogType::Channel, false, "search messages"); - if (new_full_message_id != FullMessageId()) { - CHECK(dialog_id == new_full_message_id.get_dialog_id()); - result.push_back(new_full_message_id); + if (new_message_full_id != MessageFullId()) { + CHECK(dialog_id == new_message_full_id.get_dialog_id()); + result.push_back(new_message_full_id); } else { total_count--; } @@ -10457,11 +10457,11 @@ void MessagesManager::on_get_outgoing_document_messages(vectorsent_scheduled_messages, is_channel_message, true, + auto message_full_id = on_get_message(std::move(message), d->sent_scheduled_messages, is_channel_message, true, "on_get_scheduled_server_messages"); - auto message_id = full_message_id.get_message_id(); + auto message_id = message_full_id.get_message_id(); if (message_id.is_valid_scheduled()) { CHECK(message_id.is_scheduled_server()); old_server_message_ids.erase(message_id.get_scheduled_server_message_id()); @@ -10544,15 +10544,15 @@ void MessagesManager::on_get_recent_locations(DialogId dialog_id, int32 limit, i LOG(INFO) << "Receive " << messages.size() << " recent locations in " << dialog_id; vector result; for (auto &message : messages) { - auto new_full_message_id = on_get_message(std::move(message), false, dialog_id.get_type() == DialogType::Channel, + auto new_message_full_id = on_get_message(std::move(message), false, dialog_id.get_type() == DialogType::Channel, false, "get recent locations"); - if (new_full_message_id != FullMessageId()) { - if (new_full_message_id.get_dialog_id() != dialog_id) { - LOG(ERROR) << "Receive " << new_full_message_id << " instead of a message in " << dialog_id; + if (new_message_full_id != MessageFullId()) { + if (new_message_full_id.get_dialog_id() != dialog_id) { + LOG(ERROR) << "Receive " << new_message_full_id << " instead of a message in " << dialog_id; total_count--; continue; } - auto m = get_message(new_full_message_id); + auto m = get_message(new_message_full_id); CHECK(m != nullptr); if (m->content->get_type() != MessageContentType::LiveLocation) { LOG(ERROR) << "Receive a message of wrong type " << m->content->get_type() << " in on_get_recent_locations in " @@ -10595,11 +10595,11 @@ void MessagesManager::on_get_message_public_forwards(int32 total_count, last_dialog_id = dialog_id; } - auto new_full_message_id = on_get_message(std::move(message), false, dialog_id.get_type() == DialogType::Channel, + auto new_message_full_id = on_get_message(std::move(message), false, dialog_id.get_type() == DialogType::Channel, false, "get message public forwards"); - if (new_full_message_id != FullMessageId()) { - CHECK(dialog_id == new_full_message_id.get_dialog_id()); - result.push_back(get_message_object(new_full_message_id, "on_get_message_public_forwards")); + if (new_message_full_id != MessageFullId()) { + CHECK(dialog_id == new_message_full_id.get_dialog_id()); + result.push_back(get_message_object(new_message_full_id, "on_get_message_public_forwards")); CHECK(result.back() != nullptr); } else { total_count--; @@ -10809,9 +10809,9 @@ bool MessagesManager::can_save_message(DialogId dialog_id, const Message *m) con return !get_dialog_has_protected_content(dialog_id); } -bool MessagesManager::can_get_message_statistics(FullMessageId full_message_id) { - return can_get_message_statistics(full_message_id.get_dialog_id(), - get_message_force(full_message_id, "can_get_message_statistics")); +bool MessagesManager::can_get_message_statistics(MessageFullId message_full_id) { + return can_get_message_statistics(message_full_id.get_dialog_id(), + get_message_force(message_full_id, "can_get_message_statistics")); } bool MessagesManager::can_get_message_statistics(DialogId dialog_id, const Message *m) const { @@ -11199,16 +11199,16 @@ void MessagesManager::on_failed_message_deletion(DialogId dialog_id, const vecto } Dialog *d = get_dialog(dialog_id); CHECK(d != nullptr); - vector full_message_ids; + vector message_full_ids; for (auto &server_message_id : server_message_ids) { auto message_id = MessageId(ServerMessageId(server_message_id)); d->deleted_message_ids.erase(message_id); - full_message_ids.emplace_back(dialog_id, message_id); + message_full_ids.emplace_back(dialog_id, message_id); } if (!have_input_peer(dialog_id, AccessRights::Read)) { return; } - get_messages_from_server(std::move(full_message_ids), Promise(), "on_failed_message_deletion"); + get_messages_from_server(std::move(message_full_ids), Promise(), "on_failed_message_deletion"); } void MessagesManager::on_failed_scheduled_message_deletion(DialogId dialog_id, const vector &message_ids) { @@ -13359,14 +13359,14 @@ void MessagesManager::ttl_loop(double now) { FlatHashMap, DialogIdHash> to_delete; while (!ttl_heap_.empty() && ttl_heap_.top_key() < now) { TtlNode *ttl_node = TtlNode::from_heap_node(ttl_heap_.pop()); - auto full_message_id = ttl_node->full_message_id_; - auto dialog_id = full_message_id.get_dialog_id(); + auto message_full_id = ttl_node->message_full_id_; + auto dialog_id = message_full_id.get_dialog_id(); if (dialog_id.get_type() == DialogType::SecretChat || ttl_node->by_ttl_period_) { - to_delete[dialog_id].push_back(full_message_id.get_message_id()); + to_delete[dialog_id].push_back(message_full_id.get_message_id()); } else { auto d = get_dialog(dialog_id); CHECK(d != nullptr); - auto m = get_message(d, full_message_id.get_message_id()); + auto m = get_message(d, message_full_id.get_message_id()); CHECK(m != nullptr); on_message_ttl_expired(d, m); on_message_changed(d, m, true, "ttl_loop"); @@ -13454,26 +13454,26 @@ void MessagesManager::hangup() { if (!G()->use_message_database()) { while (!being_uploaded_files_.empty()) { auto it = being_uploaded_files_.begin(); - auto full_message_id = it->second.first; + auto message_full_id = it->second.first; being_uploaded_files_.erase(it); - if (full_message_id.get_message_id().is_yet_unsent()) { - fail_send_message(full_message_id, Global::request_aborted_error()); + if (message_full_id.get_message_id().is_yet_unsent()) { + fail_send_message(message_full_id, Global::request_aborted_error()); } } while (!being_uploaded_thumbnails_.empty()) { auto it = being_uploaded_thumbnails_.begin(); - auto full_message_id = it->second.full_message_id; + auto message_full_id = it->second.message_full_id; being_uploaded_thumbnails_.erase(it); - if (full_message_id.get_message_id().is_yet_unsent()) { - fail_send_message(full_message_id, Global::request_aborted_error()); + if (message_full_id.get_message_id().is_yet_unsent()) { + fail_send_message(message_full_id, Global::request_aborted_error()); } } while (!being_loaded_secret_thumbnails_.empty()) { auto it = being_loaded_secret_thumbnails_.begin(); - auto full_message_id = it->second.full_message_id; + auto message_full_id = it->second.message_full_id; being_loaded_secret_thumbnails_.erase(it); - if (full_message_id.get_message_id().is_yet_unsent()) { - fail_send_message(full_message_id, Global::request_aborted_error()); + if (message_full_id.get_message_id().is_yet_unsent()) { + fail_send_message(message_full_id, Global::request_aborted_error()); } } while (!yet_unsent_media_queues_.empty()) { @@ -13837,8 +13837,8 @@ void MessagesManager::on_send_secret_message_error(int64 random_id, Status error auto it = being_sent_messages_.find(random_id); if (it != being_sent_messages_.end()) { - auto full_message_id = it->second; - auto *m = get_message(full_message_id); + auto message_full_id = it->second; + auto *m = get_message(message_full_id); if (m != nullptr) { auto file_id = get_message_content_upload_file_id(m->content.get()); if (file_id.is_valid()) { @@ -14369,7 +14369,7 @@ MessagesManager::MessageInfo MessagesManager::parse_telegram_api_message( if (is_scheduled) { is_content_read = false; } - auto new_source = PSTRING() << FullMessageId(message_info.dialog_id, message_info.message_id) << " sent by " + auto new_source = PSTRING() << MessageFullId(message_info.dialog_id, message_info.message_id) << " sent by " << message_info.sender_dialog_id << " from " << source; message_info.content = get_message_content( td_, @@ -14729,7 +14729,7 @@ MessageId MessagesManager::find_old_message_id(DialogId dialog_id, MessageId mes } } else { CHECK(message_id.is_server()); - auto it = update_message_ids_.find(FullMessageId(dialog_id, message_id)); + auto it = update_message_ids_.find(MessageFullId(dialog_id, message_id)); if (it != update_message_ids_.end()) { return it->second; } @@ -14749,24 +14749,24 @@ void MessagesManager::delete_update_message_id(DialogId dialog_id, MessageId mes } } else { CHECK(message_id.is_server()); - auto erased_count = update_message_ids_.erase(FullMessageId(dialog_id, message_id)); + auto erased_count = update_message_ids_.erase(MessageFullId(dialog_id, message_id)); CHECK(erased_count > 0); } } -FullMessageId MessagesManager::on_get_message(tl_object_ptr message_ptr, bool from_update, +MessageFullId MessagesManager::on_get_message(tl_object_ptr message_ptr, bool from_update, bool is_channel_message, bool is_scheduled, const char *source) { return on_get_message(parse_telegram_api_message(std::move(message_ptr), is_scheduled, source), from_update, is_channel_message, source); } -FullMessageId MessagesManager::on_get_message(MessageInfo &&message_info, const bool from_update, +MessageFullId MessagesManager::on_get_message(MessageInfo &&message_info, const bool from_update, const bool is_channel_message, const char *source) { DialogId dialog_id; unique_ptr new_message; std::tie(dialog_id, new_message) = create_message(std::move(message_info), is_channel_message); if (new_message == nullptr) { - return FullMessageId(); + return MessageFullId(); } MessageId message_id = new_message->message_id; @@ -14778,7 +14778,7 @@ FullMessageId MessagesManager::on_get_message(MessageInfo &&message_info, const MessageId old_message_id = find_old_message_id(dialog_id, message_id); bool is_sent_message = false; if (old_message_id.is_valid() || old_message_id.is_valid_scheduled()) { - LOG(INFO) << "Found temporary " << old_message_id << " for " << FullMessageId{dialog_id, message_id}; + LOG(INFO) << "Found temporary " << old_message_id << " for " << MessageFullId{dialog_id, message_id}; CHECK(d != nullptr); if (!from_update && !message_id.is_scheduled()) { @@ -14786,7 +14786,7 @@ FullMessageId MessagesManager::on_get_message(MessageInfo &&message_info, const if (get_message_force(d, message_id, "receive missed unsent message not from update") != nullptr) { LOG(ERROR) << "New " << old_message_id << "/" << message_id << " in " << dialog_id << " from " << source << " has identifier less than last_new_message_id = " << d->last_new_message_id; - return FullMessageId(); + return MessageFullId(); } // if there is no message yet, then it is likely was missed because of a server bug and is being repaired via // get_message_from_server from after_get_difference @@ -14800,7 +14800,7 @@ FullMessageId MessagesManager::on_get_message(MessageInfo &&message_info, const if (dialog_id.get_type() == DialogType::Channel && have_input_peer(dialog_id, AccessRights::Read)) { schedule_get_channel_difference(dialog_id, 0, message_id, 0.001, "on_get_message"); } - return FullMessageId(); + return MessageFullId(); } } @@ -14810,7 +14810,7 @@ FullMessageId MessagesManager::on_get_message(MessageInfo &&message_info, const // sent message is not from me LOG(ERROR) << "Sent in " << dialog_id << " " << message_id << " is sent by " << new_message->sender_user_id << "/" << new_message->sender_dialog_id; - return FullMessageId(); + return MessageFullId(); } // must be called before delete_message @@ -14821,8 +14821,8 @@ FullMessageId MessagesManager::on_get_message(MessageInfo &&message_info, const delete_message(d, old_message_id, false, &need_update_dialog_pos, "add sent message"); if (old_message == nullptr) { delete_sent_message_on_server(dialog_id, message_id, old_message_id); - being_readded_message_id_ = FullMessageId(); - return FullMessageId(); + being_readded_message_id_ = MessageFullId(); + return MessageFullId(); } old_message_id = old_message->message_id; @@ -14859,7 +14859,7 @@ FullMessageId MessagesManager::on_get_message(MessageInfo &&message_info, const const Message *m = add_message_to_dialog(d, std::move(new_message), false, from_update, &need_update, &need_update_dialog_pos, source); - being_readded_message_id_ = FullMessageId(); + being_readded_message_id_ = MessageFullId(); if (m == nullptr) { if (need_update_dialog_pos) { send_update_chat_last_message(d, "on_get_message"); @@ -14872,7 +14872,7 @@ FullMessageId MessagesManager::on_get_message(MessageInfo &&message_info, const send_update_delete_messages(dialog_id, {message_id.get()}, true); } - return FullMessageId(); + return MessageFullId(); } auto pcc_it = pending_created_dialogs_.find(dialog_id); @@ -14903,7 +14903,7 @@ FullMessageId MessagesManager::on_get_message(MessageInfo &&message_info, const CHECK(message.get() == m); send_update_delete_messages(dialog_id, {m->message_id.get()}, false); // don't need to update chat position - return FullMessageId(); + return MessageFullId(); } if (m->message_id.is_scheduled()) { @@ -14921,7 +14921,7 @@ FullMessageId MessagesManager::on_get_message(MessageInfo &&message_info, const set_dialog_reply_markup(d, message_id); } - return FullMessageId(dialog_id, message_id); + return MessageFullId(dialog_id, message_id); } void MessagesManager::set_dialog_last_message_id(Dialog *d, MessageId last_message_id, const char *source, @@ -15463,16 +15463,16 @@ void MessagesManager::on_update_sent_text_message(int64 random_id, return; } - auto full_message_id = it->second; - auto dialog_id = full_message_id.get_dialog_id(); + auto message_full_id = it->second; + auto dialog_id = message_full_id.get_dialog_id(); Dialog *d = get_dialog(dialog_id); - auto m = get_message_force(d, full_message_id.get_message_id(), "on_update_sent_text_message"); + auto m = get_message_force(d, message_full_id.get_message_id(), "on_update_sent_text_message"); if (m == nullptr) { // message has already been deleted return; } CHECK(m->message_id.is_yet_unsent()); - full_message_id = FullMessageId(dialog_id, m->message_id); + message_full_id = MessageFullId(dialog_id, m->message_id); if (m->content->get_type() != MessageContentType::Text) { LOG(ERROR) << "Text message content has been already changed to " << m->content->get_type(); @@ -15498,7 +15498,7 @@ void MessagesManager::on_update_sent_text_message(int64 random_id, is_content_changed, need_update); if (is_content_changed || need_update) { - reregister_message_content(td_, m->content.get(), new_content.get(), full_message_id, + reregister_message_content(td_, m->content.get(), new_content.get(), message_full_id, "on_update_sent_text_message"); m->content = std::move(new_content); m->is_content_secret = is_secret_message_content(m->ttl, MessageContentType::Text); @@ -15510,18 +15510,18 @@ void MessagesManager::on_update_sent_text_message(int64 random_id, } } -void MessagesManager::delete_pending_message_web_page(FullMessageId full_message_id) { - auto dialog_id = full_message_id.get_dialog_id(); +void MessagesManager::delete_pending_message_web_page(MessageFullId message_full_id) { + auto dialog_id = message_full_id.get_dialog_id(); Dialog *d = get_dialog(dialog_id); CHECK(d != nullptr); - Message *m = get_message(d, full_message_id.get_message_id()); + Message *m = get_message(d, message_full_id.get_message_id()); CHECK(m != nullptr); MessageContent *content = m->content.get(); CHECK(has_message_content_web_page(content)); - unregister_message_content(td_, content, full_message_id, "delete_pending_message_web_page"); + unregister_message_content(td_, content, message_full_id, "delete_pending_message_web_page"); remove_message_content_web_page(content); - register_message_content(td_, content, full_message_id, "delete_pending_message_web_page"); + register_message_content(td_, content, message_full_id, "delete_pending_message_web_page"); // don't need to send an updateMessageContent, because the web page was pending @@ -15588,19 +15588,19 @@ void MessagesManager::on_get_dialogs(FolderId folder_id, vector full_message_id_to_dialog_date; - FlatHashMap, FullMessageIdHash> full_message_id_to_message; + FlatHashMap message_full_id_to_dialog_date; + FlatHashMap, MessageFullIdHash> message_full_id_to_message; for (auto &message : messages) { - auto full_message_id = FullMessageId::get_full_message_id(message, false); - if (!full_message_id.get_message_id().is_valid()) { // must not check dialog_id because of messageEmpty + auto message_full_id = MessageFullId::get_message_full_id(message, false); + if (!message_full_id.get_message_id().is_valid()) { // must not check dialog_id because of messageEmpty continue; } if (from_dialog_list) { auto message_date = get_message_date(message); - int64 order = get_dialog_order(full_message_id.get_message_id(), message_date); - full_message_id_to_dialog_date.emplace(full_message_id, DialogDate(order, full_message_id.get_dialog_id())); + int64 order = get_dialog_order(message_full_id.get_message_id(), message_date); + message_full_id_to_dialog_date.emplace(message_full_id, DialogDate(order, message_full_id.get_dialog_id())); } - full_message_id_to_message[full_message_id] = std::move(message); + message_full_id_to_message[message_full_id] = std::move(message); } DialogDate max_dialog_date = MIN_DIALOG_DATE; @@ -15639,12 +15639,12 @@ void MessagesManager::on_get_dialogs(FolderId folder_id, vectortop_message_)); if (last_message_id.is_valid()) { - FullMessageId full_message_id(dialog_id, last_message_id); - auto it = full_message_id_to_dialog_date.find(full_message_id); - if (it == full_message_id_to_dialog_date.end() && dialog_id.get_type() != DialogType::Channel) { - it = full_message_id_to_dialog_date.find({DialogId(), last_message_id}); + MessageFullId message_full_id(dialog_id, last_message_id); + auto it = message_full_id_to_dialog_date.find(message_full_id); + if (it == message_full_id_to_dialog_date.end() && dialog_id.get_type() != DialogType::Channel) { + it = message_full_id_to_dialog_date.find({DialogId(), last_message_id}); } - if (it == full_message_id_to_dialog_date.end()) { + if (it == message_full_id_to_dialog_date.end()) { LOG(ERROR) << "Last " << last_message_id << " in " << dialog_id << " not found"; return promise.set_error(Status::Error(500, "Wrong query result returned: last message not found")); } @@ -15765,20 +15765,20 @@ void MessagesManager::on_get_dialogs(FolderId folder_id, vectorflags_ & DIALOG_FLAG_HAS_PTS) != 0; if (last_message_id.is_valid() && !td_->auth_manager_->is_bot()) { - FullMessageId full_message_id(dialog_id, last_message_id); - auto it = full_message_id_to_message.find(full_message_id); - if (it == full_message_id_to_message.end() && dialog_id.get_type() != DialogType::Channel) { - it = full_message_id_to_message.find({DialogId(), last_message_id}); + MessageFullId message_full_id(dialog_id, last_message_id); + auto it = message_full_id_to_message.find(message_full_id); + if (it == message_full_id_to_message.end() && dialog_id.get_type() != DialogType::Channel) { + it = message_full_id_to_message.find({DialogId(), last_message_id}); } - if (it == full_message_id_to_message.end()) { - LOG(ERROR) << "Last " << full_message_id << " not found"; + if (it == message_full_id_to_message.end()) { + LOG(ERROR) << "Last " << message_full_id << " not found"; } else if (!has_pts || d->pts == 0 || dialog->pts_ <= d->pts || d->is_channel_difference_finished) { auto last_message = std::move(it->second); - auto added_full_message_id = on_get_message(std::move(last_message), false, has_pts, false, source); + auto added_message_full_id = on_get_message(std::move(last_message), false, has_pts, false, source); CHECK(d->last_new_message_id == MessageId()); set_dialog_last_new_message_id(d, last_message_id, source); - if (d->last_new_message_id > d->last_message_id && added_full_message_id.get_message_id().is_valid()) { - CHECK(added_full_message_id.get_message_id() == d->last_new_message_id); + if (d->last_new_message_id > d->last_message_id && added_message_full_id.get_message_id().is_valid()) { + CHECK(added_message_full_id.get_message_id() == d->last_new_message_id); set_dialog_last_message_id(d, d->last_new_message_id, source); send_update_chat_last_message(d, source); } @@ -16014,9 +16014,9 @@ bool MessagesManager::can_unload_message(const Dialog *d, const Message *m) cons CHECK(d != nullptr); CHECK(m != nullptr); CHECK(m->message_id.is_valid()); - FullMessageId full_message_id{d->dialog_id, m->message_id}; + MessageFullId message_full_id{d->dialog_id, m->message_id}; if (td_->auth_manager_->is_bot() && !G()->use_message_database()) { - return !m->message_id.is_yet_unsent() && replied_by_yet_unsent_messages_.count(full_message_id) == 0 && + return !m->message_id.is_yet_unsent() && replied_by_yet_unsent_messages_.count(message_full_id) == 0 && m->edited_content == nullptr && m->message_id != d->last_pinned_message_id && m->message_id != d->last_edited_message_id; } @@ -16035,8 +16035,8 @@ bool MessagesManager::can_unload_message(const Dialog *d, const Message *m) cons } } return d->open_count == 0 && m->message_id != d->last_message_id && m->message_id != d->last_database_message_id && - !m->message_id.is_yet_unsent() && active_live_location_full_message_ids_.count(full_message_id) == 0 && - replied_by_yet_unsent_messages_.count(full_message_id) == 0 && m->edited_content == nullptr && + !m->message_id.is_yet_unsent() && active_live_location_message_full_ids_.count(message_full_id) == 0 && + replied_by_yet_unsent_messages_.count(message_full_id) == 0 && m->edited_content == nullptr && m->message_id != d->reply_markup_message_id && m->message_id != d->last_pinned_message_id && m->message_id != d->last_edited_message_id && (m->media_album_id != d->last_media_album_id || m->media_album_id == 0); @@ -16284,7 +16284,7 @@ unique_ptr MessagesManager::do_delete_message(Dialog * return nullptr; } - FullMessageId full_message_id(d->dialog_id, message_id); + MessageFullId message_full_id(d->dialog_id, message_id); const Message *m = get_message(d, message_id); if (m == nullptr) { if (only_from_memory) { @@ -16335,7 +16335,7 @@ unique_ptr MessagesManager::do_delete_message(Dialog * bool need_get_history = false; if (!only_from_memory) { - LOG(INFO) << "Deleting " << full_message_id << " from " << source; + LOG(INFO) << "Deleting " << message_full_id << " from " << source; delete_message_from_database(d, message_id, m, is_permanently_deleted, source); @@ -16376,7 +16376,7 @@ unique_ptr MessagesManager::do_delete_message(Dialog * set_dialog_last_database_message_id(d, (*it)->get_message_id(), "do_delete_message 2"); if (d->last_database_message_id < d->first_database_message_id) { LOG(ERROR) << "Last database " << d->last_database_message_id << " became less than first database " - << d->first_database_message_id << " after deletion of " << full_message_id; + << d->first_database_message_id << " after deletion of " << message_full_id; set_dialog_first_database_message_id(d, d->last_database_message_id, "do_delete_message 2"); } } @@ -16605,7 +16605,7 @@ unique_ptr MessagesManager::do_delete_scheduled_messag const Message *m = it->second.get(); CHECK(m->message_id == message_id); - LOG(INFO) << "Deleting " << FullMessageId{d->dialog_id, message_id} << " from " << source; + LOG(INFO) << "Deleting " << MessageFullId{d->dialog_id, message_id} << " from " << source; delete_message_from_database(d, message_id, m, is_permanently_deleted, source); @@ -17729,57 +17729,57 @@ void MessagesManager::on_get_blocked_dialogs(int32 offset, int32 limit, int32 to promise.set_value(td_api::make_object(total_count, std::move(senders))); } -DialogId MessagesManager::get_dialog_message_sender(FullMessageId full_message_id) { - const auto *m = get_message_force(full_message_id, "get_dialog_message_sender"); +DialogId MessagesManager::get_dialog_message_sender(MessageFullId message_full_id) { + const auto *m = get_message_force(message_full_id, "get_dialog_message_sender"); if (m == nullptr) { return DialogId(); } return get_message_sender(m); } -bool MessagesManager::have_message_force(FullMessageId full_message_id, const char *source) { - return get_message_force(full_message_id, source) != nullptr; +bool MessagesManager::have_message_force(MessageFullId message_full_id, const char *source) { + return get_message_force(message_full_id, source) != nullptr; } bool MessagesManager::have_message_force(Dialog *d, MessageId message_id, const char *source) { return get_message_force(d, message_id, source) != nullptr; } -MessagesManager::Message *MessagesManager::get_message(FullMessageId full_message_id) { - Dialog *d = get_dialog(full_message_id.get_dialog_id()); +MessagesManager::Message *MessagesManager::get_message(MessageFullId message_full_id) { + Dialog *d = get_dialog(message_full_id.get_dialog_id()); if (d == nullptr) { return nullptr; } - return get_message(d, full_message_id.get_message_id()); + return get_message(d, message_full_id.get_message_id()); } -const MessagesManager::Message *MessagesManager::get_message(FullMessageId full_message_id) const { - const Dialog *d = get_dialog(full_message_id.get_dialog_id()); +const MessagesManager::Message *MessagesManager::get_message(MessageFullId message_full_id) const { + const Dialog *d = get_dialog(message_full_id.get_dialog_id()); if (d == nullptr) { return nullptr; } - return get_message(d, full_message_id.get_message_id()); + return get_message(d, message_full_id.get_message_id()); } -MessagesManager::Message *MessagesManager::get_message_force(FullMessageId full_message_id, const char *source) { - Dialog *d = get_dialog_force(full_message_id.get_dialog_id(), source); +MessagesManager::Message *MessagesManager::get_message_force(MessageFullId message_full_id, const char *source) { + Dialog *d = get_dialog_force(message_full_id.get_dialog_id(), source); if (d == nullptr) { return nullptr; } - return get_message_force(d, full_message_id.get_message_id(), source); + return get_message_force(d, message_full_id.get_message_id(), source); } -FullMessageId MessagesManager::get_replied_message_id(DialogId dialog_id, const Message *m) { +MessageFullId MessagesManager::get_replied_message_id(DialogId dialog_id, const Message *m) { if (m->reply_to_story_full_id.is_valid()) { return {}; } - auto full_message_id = get_message_content_replied_message_id(dialog_id, m->content.get()); - if (full_message_id.get_message_id().is_valid()) { + auto message_full_id = get_message_content_replied_message_id(dialog_id, m->content.get()); + if (message_full_id.get_message_id().is_valid()) { CHECK(m->reply_to_message_id == MessageId()); - return full_message_id; + return message_full_id; } if (m->reply_to_message_id == MessageId()) { if (m->top_thread_message_id.is_valid() && is_service_message_content(m->content->get_type())) { @@ -17814,22 +17814,22 @@ void MessagesManager::get_message_force_from_server(Dialog *d, MessageId message promise.set_value(Unit()); } -void MessagesManager::get_message(FullMessageId full_message_id, Promise &&promise) { - Dialog *d = get_dialog_force(full_message_id.get_dialog_id(), "get_message"); +void MessagesManager::get_message(MessageFullId message_full_id, Promise &&promise) { + Dialog *d = get_dialog_force(message_full_id.get_dialog_id(), "get_message"); if (d == nullptr) { return promise.set_error(Status::Error(400, "Chat not found")); } - get_message_force_from_server(d, full_message_id.get_message_id(), std::move(promise)); + get_message_force_from_server(d, message_full_id.get_message_id(), std::move(promise)); } -FullMessageId MessagesManager::get_replied_message(DialogId dialog_id, MessageId message_id, bool force, +MessageFullId MessagesManager::get_replied_message(DialogId dialog_id, MessageId message_id, bool force, Promise &&promise) { LOG(INFO) << "Get replied message to " << message_id << " in " << dialog_id; Dialog *d = get_dialog_force(dialog_id, "get_replied_message"); if (d == nullptr) { promise.set_error(Status::Error(400, "Chat not found")); - return FullMessageId(); + return MessageFullId(); } message_id = get_persistent_message_id(d, message_id); @@ -17840,7 +17840,7 @@ FullMessageId MessagesManager::get_replied_message(DialogId dialog_id, MessageId } else { get_message_force_from_server(d, message_id, std::move(promise)); } - return FullMessageId(); + return MessageFullId(); } tl_object_ptr input_message; @@ -17870,7 +17870,7 @@ FullMessageId MessagesManager::get_replied_message(DialogId dialog_id, MessageId return replied_message_id; } -Result MessagesManager::get_top_thread_full_message_id(DialogId dialog_id, const Message *m, +Result MessagesManager::get_top_thread_message_full_id(DialogId dialog_id, const Message *m, bool allow_non_root) const { CHECK(m != nullptr); if (m->message_id.is_scheduled()) { @@ -17886,7 +17886,7 @@ Result MessagesManager::get_top_thread_full_message_id(DialogId d if (m->message_id.is_yet_unsent()) { return Status::Error(400, "Message is not sent yet"); } - return FullMessageId{DialogId(m->reply_info.channel_id_), m->linked_top_thread_message_id}; + return MessageFullId{DialogId(m->reply_info.channel_id_), m->linked_top_thread_message_id}; } else { if (!m->top_thread_message_id.is_valid()) { return Status::Error(400, "Message has no thread"); @@ -17895,7 +17895,7 @@ Result MessagesManager::get_top_thread_full_message_id(DialogId d !td_->contacts_manager_->get_channel_has_linked_channel(dialog_id.get_channel_id())) { return Status::Error(400, "Root message must be used to get the message thread"); } - return FullMessageId{dialog_id, m->top_thread_message_id}; + return MessageFullId{dialog_id, m->top_thread_message_id}; } } @@ -17916,9 +17916,9 @@ void MessagesManager::get_message_thread(DialogId dialog_id, MessageId message_i return promise.set_error(Status::Error(400, "Scheduled messages can't have message threads")); } - FullMessageId top_thread_full_message_id; + MessageFullId top_thread_message_full_id; if (message_id == MessageId(ServerMessageId(1)) && is_forum_channel(dialog_id)) { - top_thread_full_message_id = FullMessageId{dialog_id, message_id}; + top_thread_message_full_id = MessageFullId{dialog_id, message_id}; } else { message_id = get_persistent_message_id(d, message_id); auto m = get_message_force(d, message_id, "get_message_thread"); @@ -17926,12 +17926,12 @@ void MessagesManager::get_message_thread(DialogId dialog_id, MessageId message_i return promise.set_error(Status::Error(400, "Message not found")); } - TRY_RESULT_PROMISE_ASSIGN(promise, top_thread_full_message_id, get_top_thread_full_message_id(dialog_id, m, true)); + TRY_RESULT_PROMISE_ASSIGN(promise, top_thread_message_full_id, get_top_thread_message_full_id(dialog_id, m, true)); if ((m->reply_info.is_empty() || !m->reply_info.is_comment_) && - top_thread_full_message_id.get_message_id() != m->message_id) { - CHECK(dialog_id == top_thread_full_message_id.get_dialog_id()); + top_thread_message_full_id.get_message_id() != m->message_id) { + CHECK(dialog_id == top_thread_message_full_id.get_dialog_id()); // get information about the thread from the top message - message_id = top_thread_full_message_id.get_message_id(); + message_id = top_thread_message_full_id.get_message_id(); CHECK(message_id.is_valid()); } } @@ -17946,8 +17946,8 @@ void MessagesManager::get_message_thread(DialogId dialog_id, MessageId message_i }); td_->create_handler(std::move(query_promise)) - ->send(dialog_id, message_id, top_thread_full_message_id.get_dialog_id(), - top_thread_full_message_id.get_message_id()); + ->send(dialog_id, message_id, top_thread_message_full_id.get_dialog_id(), + top_thread_message_full_id.get_message_id()); } void MessagesManager::process_discussion_message( @@ -17995,11 +17995,11 @@ void MessagesManager::process_discussion_message_impl( message_thread_info.unread_message_count = max(0, result->unread_count_); MessageId top_message_id; for (auto &message : result->messages_) { - auto full_message_id = on_get_message(std::move(message), false, true, false, "process_discussion_message_impl"); - if (full_message_id.get_message_id().is_valid()) { - CHECK(full_message_id.get_dialog_id() == expected_dialog_id); - message_thread_info.message_ids.push_back(full_message_id.get_message_id()); - if (full_message_id.get_message_id() == expected_message_id) { + auto message_full_id = on_get_message(std::move(message), false, true, false, "process_discussion_message_impl"); + if (message_full_id.get_message_id().is_valid()) { + CHECK(message_full_id.get_dialog_id() == expected_dialog_id); + message_thread_info.message_ids.push_back(message_full_id.get_message_id()); + if (message_full_id.get_message_id() == expected_message_id) { top_message_id = expected_message_id; } } @@ -18128,14 +18128,14 @@ td_api::object_ptr MessagesManager::get_message_threa info.unread_message_count, std::move(messages), std::move(draft_message)); } -Status MessagesManager::can_get_message_viewers(FullMessageId full_message_id) { - auto dialog_id = full_message_id.get_dialog_id(); +Status MessagesManager::can_get_message_viewers(MessageFullId message_full_id) { + auto dialog_id = message_full_id.get_dialog_id(); Dialog *d = get_dialog_force(dialog_id, "get_message_viewers"); if (d == nullptr) { return Status::Error(400, "Chat not found"); } - auto m = get_message_force(d, full_message_id.get_message_id(), "get_message_viewers"); + auto m = get_message_force(d, message_full_id.get_message_id(), "get_message_viewers"); if (m == nullptr) { return Status::Error(400, "Message not found"); } @@ -18212,11 +18212,11 @@ Status MessagesManager::can_get_message_viewers(DialogId dialog_id, const Messag return Status::OK(); } -void MessagesManager::get_message_viewers(FullMessageId full_message_id, +void MessagesManager::get_message_viewers(MessageFullId message_full_id, Promise> &&promise) { - TRY_STATUS_PROMISE(promise, can_get_message_viewers(full_message_id)); + TRY_STATUS_PROMISE(promise, can_get_message_viewers(message_full_id)); - auto query_promise = PromiseCreator::lambda([actor_id = actor_id(this), dialog_id = full_message_id.get_dialog_id(), + auto query_promise = PromiseCreator::lambda([actor_id = actor_id(this), dialog_id = message_full_id.get_dialog_id(), promise = std::move(promise)](Result result) mutable { if (result.is_error()) { return promise.set_error(result.move_as_error()); @@ -18226,7 +18226,7 @@ void MessagesManager::get_message_viewers(FullMessageId full_message_id, }); td_->create_handler(std::move(query_promise)) - ->send(full_message_id.get_dialog_id(), full_message_id.get_message_id()); + ->send(message_full_id.get_dialog_id(), message_full_id.get_message_id()); } void MessagesManager::on_get_message_viewers(DialogId dialog_id, MessageViewers message_viewers, bool is_recursive, @@ -18265,9 +18265,9 @@ void MessagesManager::on_get_message_viewers(DialogId dialog_id, MessageViewers promise.set_value(message_viewers.get_message_viewers_object(td_->contacts_manager_.get())); } -void MessagesManager::translate_message_text(FullMessageId full_message_id, const string &to_language_code, +void MessagesManager::translate_message_text(MessageFullId message_full_id, const string &to_language_code, Promise> &&promise) { - auto m = get_message_force(full_message_id, "recognize_speech"); + auto m = get_message_force(message_full_id, "recognize_speech"); if (m == nullptr) { return promise.set_error(Status::Error(400, "Message not found")); } @@ -18277,33 +18277,33 @@ void MessagesManager::translate_message_text(FullMessageId full_message_id, cons return promise.set_value(td_api::make_object()); } - auto skip_bot_commands = need_skip_bot_commands(full_message_id.get_dialog_id(), m); + auto skip_bot_commands = need_skip_bot_commands(message_full_id.get_dialog_id(), m); auto max_media_timestamp = get_message_max_media_timestamp(m); td_->translation_manager_->translate_text(*text, skip_bot_commands, max_media_timestamp, to_language_code, std::move(promise)); } -void MessagesManager::recognize_speech(FullMessageId full_message_id, Promise &&promise) { - auto m = get_message_force(full_message_id, "recognize_speech"); +void MessagesManager::recognize_speech(MessageFullId message_full_id, Promise &&promise) { + auto m = get_message_force(message_full_id, "recognize_speech"); if (m == nullptr) { return promise.set_error(Status::Error(400, "Message not found")); } - auto message_id = full_message_id.get_message_id(); + auto message_id = message_full_id.get_message_id(); if (message_id.is_scheduled() || !message_id.is_server()) { return promise.set_error(Status::Error(400, "Message must be sent already")); } - recognize_message_content_speech(td_, m->content.get(), full_message_id, std::move(promise)); + recognize_message_content_speech(td_, m->content.get(), message_full_id, std::move(promise)); } -void MessagesManager::rate_speech_recognition(FullMessageId full_message_id, bool is_good, Promise &&promise) { - auto m = get_message_force(full_message_id, "rate_speech_recognition"); +void MessagesManager::rate_speech_recognition(MessageFullId message_full_id, bool is_good, Promise &&promise) { + auto m = get_message_force(message_full_id, "rate_speech_recognition"); if (m == nullptr) { return promise.set_error(Status::Error(400, "Message not found")); } - rate_message_content_speech_recognition(td_, m->content.get(), full_message_id, is_good, std::move(promise)); + rate_message_content_speech_recognition(td_, m->content.get(), message_full_id, is_good, std::move(promise)); } void MessagesManager::get_dialog_info_full(DialogId dialog_id, Promise &&promise, const char *source) { @@ -18432,7 +18432,7 @@ bool MessagesManager::get_messages(DialogId dialog_id, const vector & } bool is_secret = dialog_id.get_type() == DialogType::SecretChat; - vector missed_message_ids; + vector missed_message_ids; for (auto message_id : message_ids) { if (!message_id.is_valid() && !message_id.is_valid_scheduled()) { promise.set_error(Status::Error(400, "Invalid message identifier")); @@ -18455,13 +18455,13 @@ bool MessagesManager::get_messages(DialogId dialog_id, const vector & return true; } -void MessagesManager::get_message_from_server(FullMessageId full_message_id, Promise &&promise, +void MessagesManager::get_message_from_server(MessageFullId message_full_id, Promise &&promise, const char *source, tl_object_ptr input_message) { - get_messages_from_server({full_message_id}, std::move(promise), source, std::move(input_message)); + get_messages_from_server({message_full_id}, std::move(promise), source, std::move(input_message)); } -void MessagesManager::get_messages_from_server(vector &&message_ids, Promise &&promise, +void MessagesManager::get_messages_from_server(vector &&message_ids, Promise &&promise, const char *source, tl_object_ptr input_message) { TRY_STATUS_PROMISE(promise, G()->close_status()); @@ -18478,9 +18478,9 @@ void MessagesManager::get_messages_from_server(vector &&message_i vector> ordinary_message_ids; FlatHashMap>, ChannelIdHash> channel_message_ids; FlatHashMap, DialogIdHash> scheduled_message_ids; - for (auto &full_message_id : message_ids) { - auto dialog_id = full_message_id.get_dialog_id(); - auto message_id = full_message_id.get_message_id(); + for (auto &message_full_id : message_ids) { + auto dialog_id = message_full_id.get_dialog_id(); + auto message_id = message_full_id.get_message_id(); if (!message_id.is_valid() || !message_id.is_server()) { if (message_id.is_valid_scheduled() && message_id.is_scheduled_server() && dialog_id.is_valid()) { scheduled_message_ids[dialog_id].push_back(message_id.get_scheduled_server_message_id().get()); @@ -18501,7 +18501,7 @@ void MessagesManager::get_messages_from_server(vector &&message_i channel_message_ids[dialog_id.get_channel_id()].push_back(std::move(input_message)); break; case DialogType::SecretChat: - LOG(ERROR) << "Can't get " << full_message_id << " from server from " << source; + LOG(ERROR) << "Can't get " << message_full_id << " from server from " << source; break; case DialogType::None: default: @@ -18547,15 +18547,15 @@ void MessagesManager::get_messages_from_server(vector &&message_i lock.set_value(Unit()); } -bool MessagesManager::is_message_edited_recently(FullMessageId full_message_id, int32 seconds) { +bool MessagesManager::is_message_edited_recently(MessageFullId message_full_id, int32 seconds) { if (seconds < 0) { return false; } - if (!full_message_id.get_message_id().is_valid()) { + if (!message_full_id.get_message_id().is_valid()) { return false; } - auto m = get_message_force(full_message_id, "is_message_edited_recently"); + auto m = get_message_force(message_full_id, "is_message_edited_recently"); if (m == nullptr) { return true; } @@ -18608,9 +18608,9 @@ bool MessagesManager::can_report_message_reactions(DialogId dialog_id, const Mes return true; } -Result> MessagesManager::get_message_link(FullMessageId full_message_id, int32 media_timestamp, +Result> MessagesManager::get_message_link(MessageFullId message_full_id, int32 media_timestamp, bool for_group, bool in_message_thread) { - auto dialog_id = full_message_id.get_dialog_id(); + auto dialog_id = message_full_id.get_dialog_id(); auto d = get_dialog_force(dialog_id, "get_message_link"); if (d == nullptr) { return Status::Error(400, "Chat not found"); @@ -18619,7 +18619,7 @@ Result> MessagesManager::get_message_link(FullMessageId return Status::Error(400, "Can't access the chat"); } - auto *m = get_message_force(d, full_message_id.get_message_id(), "get_message_link"); + auto *m = get_message_force(d, message_full_id.get_message_id(), "get_message_link"); TRY_STATUS(can_get_media_timestamp_link(dialog_id, m)); if (media_timestamp <= 0 || !can_message_content_have_media_timestamp(m->content.get())) { @@ -18731,9 +18731,9 @@ Result> MessagesManager::get_message_link(FullMessageId return std::make_pair(sb.as_cslice().str(), is_public); } -string MessagesManager::get_message_embedding_code(FullMessageId full_message_id, bool for_group, +string MessagesManager::get_message_embedding_code(MessageFullId message_full_id, bool for_group, Promise &&promise) { - auto dialog_id = full_message_id.get_dialog_id(); + auto dialog_id = message_full_id.get_dialog_id(); auto d = get_dialog_force(dialog_id, "get_message_embedding_code"); if (d == nullptr) { promise.set_error(Status::Error(400, "Chat not found")); @@ -18750,7 +18750,7 @@ string MessagesManager::get_message_embedding_code(FullMessageId full_message_id return {}; } - auto *m = get_message_force(d, full_message_id.get_message_id(), "get_message_embedding_code"); + auto *m = get_message_force(d, message_full_id.get_message_id(), "get_message_embedding_code"); if (m == nullptr) { promise.set_error(Status::Error(400, "Message not found")); return {}; @@ -18784,11 +18784,11 @@ string MessagesManager::get_message_embedding_code(FullMessageId full_message_id return it->second; } -void MessagesManager::on_get_public_message_link(FullMessageId full_message_id, bool for_group, string url, +void MessagesManager::on_get_public_message_link(MessageFullId message_full_id, bool for_group, string url, string html) { - LOG_IF(ERROR, url.empty() && html.empty()) << "Receive empty public link for " << full_message_id; - auto dialog_id = full_message_id.get_dialog_id(); - auto message_id = full_message_id.get_message_id(); + LOG_IF(ERROR, url.empty() && html.empty()) << "Receive empty public link for " << message_full_id; + auto dialog_id = message_full_id.get_dialog_id(); + auto message_id = message_full_id.get_message_id(); message_embedding_codes_[for_group][dialog_id].embedding_codes_[message_id] = std::move(html); } @@ -20118,7 +20118,7 @@ Status MessagesManager::view_messages(DialogId dialog_id, vector mess on_message_changed(d, m, true, "view_messages 8"); } - auto file_source_id = full_message_id_to_file_source_id_.get({dialog_id, m->message_id}); + auto file_source_id = message_full_id_to_file_source_id_.get({dialog_id, m->message_id}); if (file_source_id.is_valid() && need_mark_download_as_viewed) { LOG(INFO) << "Have " << file_source_id << " for " << m->message_id; CHECK(file_source_id.is_valid()); @@ -20338,14 +20338,14 @@ void MessagesManager::finish_get_message_extended_media(DialogId dialog_id, cons } } -Status MessagesManager::open_message_content(FullMessageId full_message_id) { - auto dialog_id = full_message_id.get_dialog_id(); +Status MessagesManager::open_message_content(MessageFullId message_full_id) { + auto dialog_id = message_full_id.get_dialog_id(); Dialog *d = get_dialog_force(dialog_id, "open_message_content"); if (d == nullptr) { return Status::Error(400, "Chat not found"); } - auto *m = get_message_force(d, full_message_id.get_message_id(), "open_message_content"); + auto *m = get_message_force(d, message_full_id.get_message_id(), "open_message_content"); if (m == nullptr) { return Status::Error(400, "Message not found"); } @@ -20436,15 +20436,15 @@ void MessagesManager::read_message_contents_on_server(DialogId dialog_id, vector } } -void MessagesManager::click_animated_emoji_message(FullMessageId full_message_id, +void MessagesManager::click_animated_emoji_message(MessageFullId message_full_id, Promise> &&promise) { - auto dialog_id = full_message_id.get_dialog_id(); + auto dialog_id = message_full_id.get_dialog_id(); Dialog *d = get_dialog_force(dialog_id, "click_animated_emoji_message"); if (d == nullptr) { return promise.set_error(Status::Error(400, "Chat not found")); } - auto message_id = get_persistent_message_id(d, full_message_id.get_message_id()); + auto message_id = get_persistent_message_id(d, message_full_id.get_message_id()); auto *m = get_message_force(d, message_id, "click_animated_emoji_message"); if (m == nullptr) { return promise.set_error(Status::Error(400, "Message not found")); @@ -20454,7 +20454,7 @@ void MessagesManager::click_animated_emoji_message(FullMessageId full_message_id return promise.set_value(nullptr); } - get_message_content_animated_emoji_click_sticker(m->content.get(), full_message_id, td_, std::move(promise)); + get_message_content_animated_emoji_click_sticker(m->content.get(), message_full_id, td_, std::move(promise)); } void MessagesManager::open_dialog(Dialog *d) { @@ -21458,9 +21458,9 @@ std::pair> MessagesManager::get_message_thread_histo return {}; } - FullMessageId top_thread_full_message_id; + MessageFullId top_thread_message_full_id; if (message_id == MessageId(ServerMessageId(1)) && is_forum_channel(dialog_id)) { - top_thread_full_message_id = FullMessageId{dialog_id, message_id}; + top_thread_message_full_id = MessageFullId{dialog_id, message_id}; } else { message_id = get_persistent_message_id(d, message_id); Message *m = get_message_force(d, message_id, "get_message_thread_history 1"); @@ -21469,21 +21469,21 @@ std::pair> MessagesManager::get_message_thread_histo return {}; } - auto r_top_thread_full_message_id = get_top_thread_full_message_id(dialog_id, m, true); - if (r_top_thread_full_message_id.is_error()) { - promise.set_error(r_top_thread_full_message_id.move_as_error()); + auto r_top_thread_message_full_id = get_top_thread_message_full_id(dialog_id, m, true); + if (r_top_thread_message_full_id.is_error()) { + promise.set_error(r_top_thread_message_full_id.move_as_error()); return {}; } - top_thread_full_message_id = r_top_thread_full_message_id.move_as_ok(); + top_thread_message_full_id = r_top_thread_message_full_id.move_as_ok(); if ((m->reply_info.is_empty() || !m->reply_info.is_comment_) && - top_thread_full_message_id.get_message_id() != m->message_id) { - CHECK(dialog_id == top_thread_full_message_id.get_dialog_id()); + top_thread_message_full_id.get_message_id() != m->message_id) { + CHECK(dialog_id == top_thread_message_full_id.get_dialog_id()); // get information about the thread from the top message - message_id = top_thread_full_message_id.get_message_id(); + message_id = top_thread_message_full_id.get_message_id(); CHECK(message_id.is_valid()); } - if (!top_thread_full_message_id.get_message_id().is_valid()) { + if (!top_thread_message_full_id.get_message_id().is_valid()) { CHECK(m->reply_info.is_comment_); get_message_thread( dialog_id, message_id, @@ -21513,12 +21513,12 @@ std::pair> MessagesManager::get_message_thread_histo d = get_dialog(dialog_id); CHECK(d != nullptr); } - if (dialog_id != top_thread_full_message_id.get_dialog_id()) { + if (dialog_id != top_thread_message_full_id.get_dialog_id()) { promise.set_error(Status::Error(500, "Receive messages in an unexpected chat")); return {}; } - auto yet_unsent_it = yet_unsent_thread_message_ids_.find(top_thread_full_message_id); + auto yet_unsent_it = yet_unsent_thread_message_ids_.find(top_thread_message_full_id); if (yet_unsent_it != yet_unsent_thread_message_ids_.end()) { const std::set &message_ids = yet_unsent_it->second; auto merge_message_ids = get_message_history_slice(message_ids.begin(), message_ids.lower_bound(from_message_id), @@ -21529,7 +21529,7 @@ std::pair> MessagesManager::get_message_thread_histo result = std::move(new_result); } - Message *top_m = get_message_force(d, top_thread_full_message_id.get_message_id(), "get_message_thread_history 2"); + Message *top_m = get_message_force(d, top_thread_message_full_id.get_message_id(), "get_message_thread_history 2"); if (top_m != nullptr && !top_m->local_thread_message_ids.empty()) { vector &message_ids = top_m->local_thread_message_ids; vector merge_message_ids; @@ -22034,7 +22034,7 @@ void MessagesManager::search_dialog_recent_location_messages(DialogId dialog_id, } } -vector MessagesManager::get_active_live_location_messages(Promise &&promise) { +vector MessagesManager::get_active_live_location_messages(Promise &&promise) { if (!G()->use_message_database()) { are_active_live_location_messages_loaded_ = true; } @@ -22046,7 +22046,7 @@ vector MessagesManager::get_active_live_location_messages(Promise G()->td_db()->get_sqlite_pmc()->get( "di_active_live_location_messages", PromiseCreator::lambda([](string value) { send_closure(G()->messages_manager(), - &MessagesManager::on_load_active_live_location_full_message_ids_from_database, + &MessagesManager::on_load_active_live_location_message_full_ids_from_database, std::move(value)); })); } @@ -22054,9 +22054,9 @@ vector MessagesManager::get_active_live_location_messages(Promise } promise.set_value(Unit()); - vector result; - for (auto &full_message_id : active_live_location_full_message_ids_) { - auto m = get_message(full_message_id); + vector result; + for (auto &message_full_id : active_live_location_message_full_ids_) { + auto m = get_message(message_full_id); CHECK(m != nullptr); CHECK(m->content->get_type() == MessageContentType::LiveLocation); CHECK(!m->message_id.is_scheduled()); @@ -22070,13 +22070,13 @@ vector MessagesManager::get_active_live_location_messages(Promise // live location is expired continue; } - result.push_back(full_message_id); + result.push_back(message_full_id); } return result; } -void MessagesManager::on_load_active_live_location_full_message_ids_from_database(string value) { +void MessagesManager::on_load_active_live_location_message_full_ids_from_database(string value) { if (G()->close_flag()) { return; } @@ -22084,7 +22084,7 @@ void MessagesManager::on_load_active_live_location_full_message_ids_from_databas LOG(INFO) << "Active live location messages aren't found in the database"; on_load_active_live_location_messages_finished(); - if (!active_live_location_full_message_ids_.empty()) { + if (!active_live_location_message_full_ids_.empty()) { save_active_live_locations(); } return; @@ -22092,26 +22092,26 @@ void MessagesManager::on_load_active_live_location_full_message_ids_from_databas LOG(INFO) << "Successfully loaded active live location messages list of size " << value.size() << " from database"; - auto new_full_message_ids = std::move(active_live_location_full_message_ids_); - vector old_full_message_ids; - log_event_parse(old_full_message_ids, value).ensure(); + auto new_message_full_ids = std::move(active_live_location_message_full_ids_); + vector old_message_full_ids; + log_event_parse(old_message_full_ids, value).ensure(); // TODO asynchronously load messages from database - active_live_location_full_message_ids_.clear(); - for (const auto &full_message_id : old_full_message_ids) { - Message *m = get_message_force(full_message_id, "on_load_active_live_location_full_message_ids_from_database"); + active_live_location_message_full_ids_.clear(); + for (const auto &message_full_id : old_message_full_ids) { + Message *m = get_message_force(message_full_id, "on_load_active_live_location_message_full_ids_from_database"); if (m != nullptr) { - try_add_active_live_location(full_message_id.get_dialog_id(), m); + try_add_active_live_location(message_full_id.get_dialog_id(), m); } } - for (const auto &full_message_id : new_full_message_ids) { - add_active_live_location(full_message_id); + for (const auto &message_full_id : new_message_full_ids) { + add_active_live_location(message_full_id); } on_load_active_live_location_messages_finished(); - if (!new_full_message_ids.empty() || old_full_message_ids.size() != active_live_location_full_message_ids_.size()) { + if (!new_message_full_ids.empty() || old_message_full_ids.size() != active_live_location_message_full_ids_.size()) { save_active_live_locations(); } } @@ -22140,11 +22140,11 @@ void MessagesManager::try_add_active_live_location(DialogId dialog_id, const Mes add_active_live_location({dialog_id, m->message_id}); } -void MessagesManager::add_active_live_location(FullMessageId full_message_id) { +void MessagesManager::add_active_live_location(MessageFullId message_full_id) { if (td_->auth_manager_->is_bot()) { return; } - if (!active_live_location_full_message_ids_.insert(full_message_id).second) { + if (!active_live_location_message_full_ids_.insert(message_full_id).second) { return; } @@ -22164,15 +22164,15 @@ void MessagesManager::add_active_live_location(FullMessageId full_message_id) { bool MessagesManager::delete_active_live_location(DialogId dialog_id, const Message *m) { CHECK(m != nullptr); - return active_live_location_full_message_ids_.erase(FullMessageId{dialog_id, m->message_id}) != 0; + return active_live_location_message_full_ids_.erase(MessageFullId{dialog_id, m->message_id}) != 0; } void MessagesManager::save_active_live_locations() { CHECK(are_active_live_location_messages_loaded_); - LOG(INFO) << "Save active live locations of size " << active_live_location_full_message_ids_.size() << " to database"; + LOG(INFO) << "Save active live locations of size " << active_live_location_message_full_ids_.size() << " to database"; if (G()->use_message_database()) { G()->td_db()->get_sqlite_pmc()->set("di_active_live_location_messages", - log_event_store(active_live_location_full_message_ids_).as_slice().str(), + log_event_store(active_live_location_message_full_ids_).as_slice().str(), Auto()); } } @@ -22221,9 +22221,9 @@ void MessagesManager::on_message_live_location_viewed(Dialog *d, const Message * } live_location_task_id = ++viewed_live_location_task_id_; - auto &full_message_id = viewed_live_location_tasks_[live_location_task_id]; - full_message_id = FullMessageId(d->dialog_id, m->message_id); - view_message_live_location_on_server_impl(live_location_task_id, full_message_id); + auto &message_full_id = viewed_live_location_tasks_[live_location_task_id]; + message_full_id = MessageFullId(d->dialog_id, m->message_id); + view_message_live_location_on_server_impl(live_location_task_id, message_full_id); } void MessagesManager::view_message_live_location_on_server(int64 task_id) { @@ -22236,15 +22236,15 @@ void MessagesManager::view_message_live_location_on_server(int64 task_id) { return; } - auto full_message_id = it->second; - Dialog *d = get_dialog(full_message_id.get_dialog_id()); - const Message *m = get_message_force(d, full_message_id.get_message_id(), "view_message_live_location_on_server"); + auto message_full_id = it->second; + Dialog *d = get_dialog(message_full_id.get_dialog_id()); + const Message *m = get_message_force(d, message_full_id.get_message_id(), "view_message_live_location_on_server"); if (m == nullptr || get_message_content_live_location_period(m->content.get()) <= G()->unix_time() - m->date + 1) { // the message was deleted or live location is expired viewed_live_location_tasks_.erase(it); auto live_locations_it = pending_viewed_live_locations_.find(d->dialog_id); CHECK(live_locations_it != pending_viewed_live_locations_.end()); - auto erased_count = live_locations_it->second.erase(full_message_id.get_message_id()); + auto erased_count = live_locations_it->second.erase(message_full_id.get_message_id()); CHECK(erased_count > 0); if (live_locations_it->second.empty()) { pending_viewed_live_locations_.erase(live_locations_it); @@ -22252,14 +22252,14 @@ void MessagesManager::view_message_live_location_on_server(int64 task_id) { return; } - view_message_live_location_on_server_impl(task_id, full_message_id); + view_message_live_location_on_server_impl(task_id, message_full_id); } -void MessagesManager::view_message_live_location_on_server_impl(int64 task_id, FullMessageId full_message_id) { +void MessagesManager::view_message_live_location_on_server_impl(int64 task_id, MessageFullId message_full_id) { auto promise = PromiseCreator::lambda([actor_id = actor_id(this), task_id](Unit result) { send_closure(actor_id, &MessagesManager::on_message_live_location_viewed_on_server, task_id); }); - read_message_contents_on_server(full_message_id.get_dialog_id(), {full_message_id.get_message_id()}, 0, + read_message_contents_on_server(message_full_id.get_dialog_id(), {message_full_id.get_message_id()}, 0, std::move(promise), true); } @@ -22299,23 +22299,23 @@ void MessagesManager::delete_bot_command_message_id(DialogId dialog_id, MessageI } } -FileSourceId MessagesManager::get_message_file_source_id(FullMessageId full_message_id, bool force) { +FileSourceId MessagesManager::get_message_file_source_id(MessageFullId message_full_id, bool force) { if (!force) { if (td_->auth_manager_->is_bot()) { return FileSourceId(); } - auto dialog_id = full_message_id.get_dialog_id(); - auto message_id = full_message_id.get_message_id(); + auto dialog_id = message_full_id.get_dialog_id(); + auto message_id = message_full_id.get_message_id(); if (!dialog_id.is_valid() || !(message_id.is_valid() || message_id.is_valid_scheduled()) || dialog_id.get_type() == DialogType::SecretChat || !message_id.is_any_server()) { return FileSourceId(); } } - auto &file_source_id = full_message_id_to_file_source_id_[full_message_id]; + auto &file_source_id = message_full_id_to_file_source_id_[message_full_id]; if (!file_source_id.is_valid()) { - file_source_id = td_->file_reference_manager_->create_message_file_source(full_message_id); + file_source_id = td_->file_reference_manager_->create_message_file_source(message_full_id); } return file_source_id; } @@ -22335,7 +22335,7 @@ void MessagesManager::add_message_file_sources(DialogId dialog_id, const Message } // do not create file_source_id for messages without file_ids - auto file_source_id = get_message_file_source_id(FullMessageId(dialog_id, m->message_id)); + auto file_source_id = get_message_file_source_id(MessageFullId(dialog_id, m->message_id)); if (file_source_id.is_valid()) { for (auto file_id : file_ids) { td_->file_manager_->add_file_source(file_id, file_source_id); @@ -22354,7 +22354,7 @@ void MessagesManager::remove_message_file_sources(DialogId dialog_id, const Mess } // do not create file_source_id for messages without file_ids - auto file_source_id = get_message_file_source_id(FullMessageId(dialog_id, m->message_id)); + auto file_source_id = get_message_file_source_id(MessageFullId(dialog_id, m->message_id)); if (file_source_id.is_valid()) { for (auto file_id : file_ids) { auto file_view = td_->file_manager_->get_file_view(file_id); @@ -22375,12 +22375,12 @@ void MessagesManager::change_message_files(DialogId dialog_id, const Message *m, return; } - FullMessageId full_message_id{dialog_id, m->message_id}; + MessageFullId message_full_id{dialog_id, m->message_id}; bool need_delete_files = need_delete_message_files(dialog_id, m); - auto file_source_id = get_message_file_source_id(full_message_id); + auto file_source_id = get_message_file_source_id(message_full_id); for (auto file_id : old_file_ids) { if (!td::contains(new_file_ids, file_id)) { - if (need_delete_files && need_delete_file(full_message_id, file_id)) { + if (need_delete_files && need_delete_file(message_full_id, file_id)) { send_closure(G()->file_manager(), &FileManager::delete_file, file_id, Promise(), "change_message_files"); } if (file_source_id.is_valid()) { @@ -22511,9 +22511,9 @@ td_api::object_ptr MessagesManager::get_found_chat_me td_api::object_ptr MessagesManager::get_found_messages_object( const FoundMessages &found_messages, const char *source) { vector> result; - result.reserve(found_messages.full_message_ids.size()); - for (const auto &full_message_id : found_messages.full_message_ids) { - auto message = get_message_object(full_message_id, source); + result.reserve(found_messages.message_full_ids.size()); + for (const auto &message_full_id : found_messages.message_full_ids) { + auto message = get_message_object(message_full_id, source); if (message != nullptr) { result.push_back(std::move(message)); } @@ -22599,7 +22599,7 @@ void MessagesManager::on_message_db_fts_result(Result result auto it = found_fts_messages_.find(random_id); CHECK(it != found_fts_messages_.end()); - auto &res = it->second.full_message_ids; + auto &res = it->second.message_full_ids; res.reserve(fts_result.messages.size()); for (auto &message : fts_result.messages) { @@ -22629,7 +22629,7 @@ void MessagesManager::on_message_db_calls_result(Result re auto it = found_call_messages_.find(random_id); CHECK(it != found_call_messages_.end()); - auto &res = it->second.full_message_ids; + auto &res = it->second.message_full_ids; CHECK(!first_db_message_id.is_scheduled()); res.reserve(calls_result.messages.size()); @@ -22894,7 +22894,7 @@ void MessagesManager::on_get_dialog_message_by_date_success(DialogId dialog_id, auto it = get_dialog_message_by_date_results_.find(random_id); CHECK(it != get_dialog_message_by_date_results_.end()); auto &result = it->second; - CHECK(result == FullMessageId()); + CHECK(result == MessageFullId()); for (auto &message : messages) { auto message_date = get_message_date(message); @@ -22906,7 +22906,7 @@ void MessagesManager::on_get_dialog_message_by_date_success(DialogId dialog_id, if (message_date != 0 && message_date <= date) { result = on_get_message(std::move(message), false, dialog_id.get_type() == DialogType::Channel, false, "on_get_dialog_message_by_date_success"); - if (result != FullMessageId()) { + if (result != MessageFullId()) { const Dialog *d = get_dialog(dialog_id); CHECK(d != nullptr); auto message_id = d->ordered_messages.find_message_by_date(date, get_get_message_date(d)); @@ -22932,9 +22932,9 @@ void MessagesManager::on_get_dialog_message_by_date_fail(int64 random_id) { tl_object_ptr MessagesManager::get_dialog_message_by_date_object(int64 random_id) { auto it = get_dialog_message_by_date_results_.find(random_id); CHECK(it != get_dialog_message_by_date_results_.end()); - auto full_message_id = std::move(it->second); + auto message_full_id = std::move(it->second); get_dialog_message_by_date_results_.erase(it); - return get_message_object(full_message_id, "get_dialog_message_by_date_object"); + return get_message_object(message_full_id, "get_dialog_message_by_date_object"); } void MessagesManager::get_dialog_sparse_message_positions( @@ -23070,9 +23070,9 @@ void MessagesManager::get_dialog_message_count_from_server(DialogId dialog_id, M } } -void MessagesManager::get_dialog_message_position(FullMessageId full_message_id, MessageSearchFilter filter, +void MessagesManager::get_dialog_message_position(MessageFullId message_full_id, MessageSearchFilter filter, MessageId top_thread_message_id, Promise &&promise) { - auto dialog_id = full_message_id.get_dialog_id(); + auto dialog_id = message_full_id.get_dialog_id(); Dialog *d = get_dialog_force(dialog_id, "get_dialog_message_position"); if (d == nullptr) { return promise.set_error(Status::Error(400, "Chat not found")); @@ -23081,7 +23081,7 @@ void MessagesManager::get_dialog_message_position(FullMessageId full_message_id, return promise.set_error(Status::Error(400, "Can't access the chat")); } - auto message_id = full_message_id.get_message_id(); + auto message_id = message_full_id.get_message_id(); const Message *m = get_message_force(d, message_id, "get_dialog_message_position"); if (m == nullptr) { return promise.set_error(Status::Error(400, "Message not found")); @@ -23799,14 +23799,14 @@ void MessagesManager::on_get_scheduled_messages_from_database(DialogId dialog_id } Result> MessagesManager::get_message_available_reactions( - FullMessageId full_message_id, int32 row_size) { - auto dialog_id = full_message_id.get_dialog_id(); + MessageFullId message_full_id, int32 row_size) { + auto dialog_id = message_full_id.get_dialog_id(); Dialog *d = get_dialog_force(dialog_id, "get_message_available_reactions"); if (d == nullptr) { return Status::Error(400, "Chat not found"); } - const Message *m = get_message_force(d, full_message_id.get_message_id(), "get_message_available_reactions"); + const Message *m = get_message_force(d, message_full_id.get_message_id(), "get_message_available_reactions"); if (m == nullptr) { return Status::Error(400, "Message not found"); } @@ -23862,15 +23862,15 @@ ChatReactions MessagesManager::get_message_available_reactions(const Dialog *d, return active_reactions; } -void MessagesManager::add_message_reaction(FullMessageId full_message_id, ReactionType reaction_type, bool is_big, +void MessagesManager::add_message_reaction(MessageFullId message_full_id, ReactionType reaction_type, bool is_big, bool add_to_recent, Promise &&promise) { - auto dialog_id = full_message_id.get_dialog_id(); + auto dialog_id = message_full_id.get_dialog_id(); Dialog *d = get_dialog_force(dialog_id, "add_message_reaction"); if (d == nullptr) { return promise.set_error(Status::Error(400, "Chat not found")); } - Message *m = get_message_force(d, full_message_id.get_message_id(), "add_message_reaction"); + Message *m = get_message_force(d, message_full_id.get_message_id(), "add_message_reaction"); if (m == nullptr) { return promise.set_error(Status::Error(400, "Message not found")); } @@ -23899,15 +23899,15 @@ void MessagesManager::add_message_reaction(FullMessageId full_message_id, Reacti set_message_reactions(d, m, is_big, add_to_recent, std::move(promise)); } -void MessagesManager::remove_message_reaction(FullMessageId full_message_id, ReactionType reaction_type, +void MessagesManager::remove_message_reaction(MessageFullId message_full_id, ReactionType reaction_type, Promise &&promise) { - auto dialog_id = full_message_id.get_dialog_id(); + auto dialog_id = message_full_id.get_dialog_id(); Dialog *d = get_dialog_force(dialog_id, "remove_message_reaction"); if (d == nullptr) { return promise.set_error(Status::Error(400, "Chat not found")); } - Message *m = get_message_force(d, full_message_id.get_message_id(), "remove_message_reaction"); + Message *m = get_message_force(d, message_full_id.get_message_id(), "remove_message_reaction"); if (m == nullptr) { return promise.set_error(Status::Error(400, "Message not found")); } @@ -23932,40 +23932,40 @@ void MessagesManager::set_message_reactions(Dialog *d, Message *m, bool is_big, LOG(INFO) << "Update message reactions to " << *m->reactions; - FullMessageId full_message_id{d->dialog_id, m->message_id}; - pending_reactions_[full_message_id].query_count++; + MessageFullId message_full_id{d->dialog_id, m->message_id}; + pending_reactions_[message_full_id].query_count++; send_update_message_interaction_info(d->dialog_id, m); on_message_changed(d, m, true, "set_message_reactions"); // TODO cancel previous queries, log event auto query_promise = PromiseCreator::lambda( - [actor_id = actor_id(this), full_message_id, promise = std::move(promise)](Result &&result) mutable { - send_closure(actor_id, &MessagesManager::on_set_message_reactions, full_message_id, std::move(result), + [actor_id = actor_id(this), message_full_id, promise = std::move(promise)](Result &&result) mutable { + send_closure(actor_id, &MessagesManager::on_set_message_reactions, message_full_id, std::move(result), std::move(promise)); }); - send_message_reaction(td_, full_message_id, m->reactions->get_chosen_reaction_types(), is_big, add_to_recent, + send_message_reaction(td_, message_full_id, m->reactions->get_chosen_reaction_types(), is_big, add_to_recent, std::move(query_promise)); } -void MessagesManager::on_set_message_reactions(FullMessageId full_message_id, Result result, +void MessagesManager::on_set_message_reactions(MessageFullId message_full_id, Result result, Promise promise) { TRY_STATUS_PROMISE(promise, G()->close_status()); bool need_reload = result.is_error(); - auto it = pending_reactions_.find(full_message_id); + auto it = pending_reactions_.find(message_full_id); CHECK(it != pending_reactions_.end()); if (--it->second.query_count == 0) { // need_reload |= it->second.was_updated; pending_reactions_.erase(it); } - if (!have_message_force(full_message_id, "on_set_message_reactions")) { + if (!have_message_force(message_full_id, "on_set_message_reactions")) { return promise.set_value(Unit()); } if (need_reload) { - queue_message_reactions_reload(full_message_id); + queue_message_reactions_reload(message_full_id); } promise.set_result(std::move(result)); @@ -23974,47 +23974,47 @@ void MessagesManager::on_set_message_reactions(FullMessageId full_message_id, Re void MessagesManager::on_read_message_reactions(DialogId dialog_id, vector &&message_ids, Result &&result) { for (auto message_id : message_ids) { - FullMessageId full_message_id{dialog_id, message_id}; - auto it = pending_read_reactions_.find(full_message_id); + MessageFullId message_full_id{dialog_id, message_id}; + auto it = pending_read_reactions_.find(message_full_id); CHECK(it != pending_read_reactions_.end()); if (--it->second == 0) { pending_read_reactions_.erase(it); } - if (!have_message_force(full_message_id, "on_read_message_reactions")) { + if (!have_message_force(message_full_id, "on_read_message_reactions")) { continue; } if (result.is_error()) { - queue_message_reactions_reload(full_message_id); + queue_message_reactions_reload(message_full_id); } } } -void MessagesManager::get_message_public_forwards(FullMessageId full_message_id, string offset, int32 limit, +void MessagesManager::get_message_public_forwards(MessageFullId message_full_id, string offset, int32 limit, Promise> &&promise) { - auto dc_id_promise = PromiseCreator::lambda([actor_id = actor_id(this), full_message_id, offset = std::move(offset), + auto dc_id_promise = PromiseCreator::lambda([actor_id = actor_id(this), message_full_id, offset = std::move(offset), limit, promise = std::move(promise)](Result r_dc_id) mutable { if (r_dc_id.is_error()) { return promise.set_error(r_dc_id.move_as_error()); } send_closure(actor_id, &MessagesManager::send_get_message_public_forwards_query, r_dc_id.move_as_ok(), - full_message_id, std::move(offset), limit, std::move(promise)); + message_full_id, std::move(offset), limit, std::move(promise)); }); - td_->contacts_manager_->get_channel_statistics_dc_id(full_message_id.get_dialog_id(), false, + td_->contacts_manager_->get_channel_statistics_dc_id(message_full_id.get_dialog_id(), false, std::move(dc_id_promise)); } void MessagesManager::send_get_message_public_forwards_query( - DcId dc_id, FullMessageId full_message_id, string offset, int32 limit, + DcId dc_id, MessageFullId message_full_id, string offset, int32 limit, Promise> &&promise) { - auto dialog_id = full_message_id.get_dialog_id(); + auto dialog_id = message_full_id.get_dialog_id(); Dialog *d = get_dialog_force(dialog_id, "send_get_message_public_forwards_query"); if (d == nullptr) { return promise.set_error(Status::Error(400, "Chat not found")); } - const Message *m = get_message_force(d, full_message_id.get_message_id(), "send_get_message_public_forwards_query"); + const Message *m = get_message_force(d, message_full_id.get_message_id(), "send_get_message_public_forwards_query"); if (m == nullptr) { return promise.set_error(Status::Error(400, "Message not found")); } @@ -24053,7 +24053,7 @@ void MessagesManager::send_get_message_public_forwards_query( } td_->create_handler(std::move(promise)) - ->send(dc_id, full_message_id, offset_date, offset_dialog_id, offset_server_message_id, limit); + ->send(dc_id, message_full_id, offset_date, offset_dialog_id, offset_server_message_id, limit); } Result MessagesManager::get_message_schedule_date( @@ -24140,8 +24140,8 @@ td_api::object_ptr MessagesManager::get_dialog_event_log_messag get_restriction_reason_description(m->restriction_reasons), std::move(content), std::move(reply_markup)); } -tl_object_ptr MessagesManager::get_message_object(FullMessageId full_message_id, const char *source) { - return get_message_object(full_message_id.get_dialog_id(), get_message_force(full_message_id, source), source); +tl_object_ptr MessagesManager::get_message_object(MessageFullId message_full_id, const char *source) { + return get_message_object(message_full_id.get_dialog_id(), get_message_force(message_full_id, source), source); } tl_object_ptr MessagesManager::get_message_object(DialogId dialog_id, const Message *m, @@ -24204,7 +24204,7 @@ tl_object_ptr MessagesManager::get_message_object(DialogId dial auto can_be_forwarded = can_be_saved && can_forward_message(dialog_id, m); 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_full_message_id(dialog_id, m, false).is_ok(); + auto can_get_message_thread = get_top_thread_message_full_id(dialog_id, m, false).is_ok(); auto can_get_viewers = can_get_message_viewers(dialog_id, m).is_ok(); auto can_get_media_timestamp_links = can_get_media_timestamp_link(dialog_id, m).is_ok(); auto can_report_reactions = can_report_message_reactions(dialog_id, m); @@ -24271,10 +24271,10 @@ tl_object_ptr MessagesManager::get_messages_object(int32 total } tl_object_ptr MessagesManager::get_messages_object(int32 total_count, - const vector &full_message_ids, + const vector &message_full_ids, bool skip_not_found, const char *source) { - auto message_objects = transform(full_message_ids, [this, source](FullMessageId full_message_id) { - return get_message_object(full_message_id, source); + auto message_objects = transform(message_full_ids, [this, source](MessageFullId message_full_id) { + return get_message_object(message_full_id, source); }); return get_messages_object(total_count, std::move(message_objects), skip_not_found); } @@ -24522,10 +24522,10 @@ MessagesManager::Message *MessagesManager::get_message_to_send( } int64 MessagesManager::begin_send_message(DialogId dialog_id, const Message *m) { - LOG(INFO) << "Begin to send " << FullMessageId(dialog_id, m->message_id) << " with random_id = " << m->random_id; + LOG(INFO) << "Begin to send " << MessageFullId(dialog_id, m->message_id) << " with random_id = " << m->random_id; CHECK(m->random_id != 0); CHECK(m->message_id.is_yet_unsent()); - bool is_inserted = being_sent_messages_.emplace(m->random_id, FullMessageId(dialog_id, m->message_id)).second; + bool is_inserted = being_sent_messages_.emplace(m->random_id, MessageFullId(dialog_id, m->message_id)).second; CHECK(is_inserted); return m->random_id; } @@ -24564,8 +24564,8 @@ MessageId MessagesManager::get_persistent_message_id(const Dialog *d, MessageId if (message_id.is_yet_unsent()) { // it is possible that user tries to do something with an already sent message by its temporary identifier // we need to use real message in this case and transparently replace message_id - auto it = yet_unsent_full_message_id_to_persistent_message_id_.find({d->dialog_id, message_id}); - if (it != yet_unsent_full_message_id_to_persistent_message_id_.end()) { + auto it = yet_unsent_message_full_id_to_persistent_message_id_.find({d->dialog_id, message_id}); + if (it != yet_unsent_message_full_id_to_persistent_message_id_.end()) { return it->second; } } @@ -25330,7 +25330,7 @@ void MessagesManager::save_send_message_log_event(DialogId dialog_id, const Mess } CHECK(m != nullptr); - LOG(INFO) << "Save " << FullMessageId(dialog_id, m->message_id) << " to binlog"; + LOG(INFO) << "Save " << MessageFullId(dialog_id, m->message_id) << " to binlog"; auto log_event = SendMessageLogEvent(dialog_id, m); CHECK(m->send_message_log_event_id == 0); m->send_message_log_event_id = @@ -25339,7 +25339,7 @@ void MessagesManager::save_send_message_log_event(DialogId dialog_id, const Mess void MessagesManager::do_send_message(DialogId dialog_id, const Message *m, vector bad_parts) { bool is_edit = m->message_id.is_any_server(); - LOG(INFO) << "Do " << (is_edit ? "edit" : "send") << ' ' << FullMessageId(dialog_id, m->message_id); + LOG(INFO) << "Do " << (is_edit ? "edit" : "send") << ' ' << MessageFullId(dialog_id, m->message_id); bool is_secret = dialog_id.get_type() == DialogType::SecretChat; if (m->media_album_id != 0 && bad_parts.empty() && !is_secret && !is_edit) { @@ -25374,7 +25374,7 @@ void MessagesManager::do_send_message(DialogId dialog_id, const Message *m, vect CHECK(file_id.is_valid()); bool is_inserted = being_uploaded_files_ - .emplace(file_id, std::make_pair(FullMessageId(dialog_id, m->message_id), thumbnail_file_id)) + .emplace(file_id, std::make_pair(MessageFullId(dialog_id, m->message_id), thumbnail_file_id)) .second; CHECK(is_inserted); // need to call resume_upload synchronously to make upload process consistent with being_uploaded_files_ @@ -25398,7 +25398,7 @@ void MessagesManager::do_send_message(DialogId dialog_id, const Message *m, vect CHECK(file_id.is_valid()); bool is_inserted = being_uploaded_files_ - .emplace(file_id, std::make_pair(FullMessageId(dialog_id, m->message_id), thumbnail_file_id)) + .emplace(file_id, std::make_pair(MessageFullId(dialog_id, m->message_id), thumbnail_file_id)) .second; CHECK(is_inserted); // need to call resume_upload synchronously to make upload process consistent with being_uploaded_files_ @@ -25597,7 +25597,7 @@ void MessagesManager::on_upload_message_media_success(DialogId dialog_id, Messag // don't need to send error to the user, because the message has already been deleted // and there is nothing to be deleted from the server LOG(INFO) << "Don't need to send already deleted by the user or sent to an inaccessible chat " - << FullMessageId{dialog_id, message_id}; + << MessageFullId{dialog_id, message_id}; return; } @@ -25641,7 +25641,7 @@ void MessagesManager::on_upload_message_media_file_parts_missing(DialogId dialog // don't need to send error to the user, because the message has already been deleted // and there is nothing to be deleted from the server LOG(INFO) << "Don't need to send already deleted by the user or sent to an inaccessible chat " - << FullMessageId{dialog_id, message_id}; + << MessageFullId{dialog_id, message_id}; return; } @@ -25664,7 +25664,7 @@ void MessagesManager::on_upload_message_media_fail(DialogId dialog_id, MessageId // don't need to send error to the user, because the message has already been deleted // and there is nothing to be deleted from the server LOG(INFO) << "Don't need to send already deleted by the user or sent to an inaccessible chat " - << FullMessageId{dialog_id, message_id}; + << MessageFullId{dialog_id, message_id}; return; } @@ -25945,7 +25945,7 @@ void MessagesManager::on_yet_unsent_media_queue_updated(DialogId dialog_id) { // don't use it/queue/first_it after promise is called if (m != nullptr) { - LOG(INFO) << "Can send " << FullMessageId{dialog_id, m->message_id}; + LOG(INFO) << "Can send " << MessageFullId{dialog_id, m->message_id}; promise.set_value(std::move(m)); } else { promise.set_error(Status::Error(400, "Message not found")); @@ -26078,7 +26078,7 @@ void MessagesManager::save_send_bot_start_message_log_event(UserId bot_user_id, } CHECK(m != nullptr); - LOG(INFO) << "Save " << FullMessageId(dialog_id, m->message_id) << " to binlog"; + LOG(INFO) << "Save " << MessageFullId(dialog_id, m->message_id) << " to binlog"; SendBotStartMessageLogEvent log_event; log_event.bot_user_id = bot_user_id; log_event.dialog_id = dialog_id; @@ -26095,7 +26095,7 @@ void MessagesManager::do_send_bot_start_message(UserId bot_user_id, DialogId dia return; } - LOG(INFO) << "Do send bot start " << FullMessageId(dialog_id, message_id) << " to bot " << bot_user_id; + LOG(INFO) << "Do send bot start " << MessageFullId(dialog_id, message_id) << " to bot " << bot_user_id; auto m = get_message({dialog_id, message_id}); if (m == nullptr) { @@ -26232,7 +26232,7 @@ void MessagesManager::save_send_inline_query_result_message_log_event(DialogId d } CHECK(m != nullptr); - LOG(INFO) << "Save " << FullMessageId(dialog_id, m->message_id) << " to binlog"; + LOG(INFO) << "Save " << MessageFullId(dialog_id, m->message_id) << " to binlog"; SendInlineQueryResultMessageLogEvent log_event; log_event.dialog_id = dialog_id; log_event.query_id = query_id; @@ -26249,7 +26249,7 @@ void MessagesManager::do_send_inline_query_result_message(DialogId dialog_id, Me return; } - LOG(INFO) << "Do send inline query result " << FullMessageId(dialog_id, message_id); + LOG(INFO) << "Do send inline query result " << MessageFullId(dialog_id, message_id); auto m = get_message({dialog_id, message_id}); if (m == nullptr) { @@ -26569,7 +26569,7 @@ DialogId MessagesManager::get_message_sender(const Message *m) { return m->sender_dialog_id.is_valid() ? m->sender_dialog_id : DialogId(m->sender_user_id); } -void MessagesManager::edit_message_text(FullMessageId full_message_id, +void MessagesManager::edit_message_text(MessageFullId message_full_id, tl_object_ptr &&reply_markup, tl_object_ptr &&input_message_content, Promise &&promise) { @@ -26581,7 +26581,7 @@ void MessagesManager::edit_message_text(FullMessageId full_message_id, return promise.set_error(Status::Error(400, "Input message content type must be InputMessageText")); } - auto dialog_id = full_message_id.get_dialog_id(); + auto dialog_id = message_full_id.get_dialog_id(); Dialog *d = get_dialog_force(dialog_id, "edit_message_text"); if (d == nullptr) { return promise.set_error(Status::Error(400, "Chat not found")); @@ -26591,7 +26591,7 @@ void MessagesManager::edit_message_text(FullMessageId full_message_id, return promise.set_error(Status::Error(400, "Can't access the chat")); } - const Message *m = get_message_force(d, full_message_id.get_message_id(), "edit_message_text"); + const Message *m = get_message_force(d, message_full_id.get_message_id(), "edit_message_text"); if (m == nullptr) { return promise.set_error(Status::Error(400, "Message not found")); } @@ -26630,11 +26630,11 @@ void MessagesManager::edit_message_text(FullMessageId full_message_id, nullptr, std::move(input_reply_markup), get_message_schedule_date(m)); } -void MessagesManager::edit_message_live_location(FullMessageId full_message_id, +void MessagesManager::edit_message_live_location(MessageFullId message_full_id, tl_object_ptr &&reply_markup, tl_object_ptr &&input_location, int32 heading, int32 proximity_alert_radius, Promise &&promise) { - auto dialog_id = full_message_id.get_dialog_id(); + auto dialog_id = message_full_id.get_dialog_id(); Dialog *d = get_dialog_force(dialog_id, "edit_message_live_location"); if (d == nullptr) { return promise.set_error(Status::Error(400, "Chat not found")); @@ -26644,7 +26644,7 @@ void MessagesManager::edit_message_live_location(FullMessageId full_message_id, return promise.set_error(Status::Error(400, "Can't access the chat")); } - const Message *m = get_message_force(d, full_message_id.get_message_id(), "edit_message_live_location"); + const Message *m = get_message_force(d, message_full_id.get_message_id(), "edit_message_live_location"); if (m == nullptr) { return promise.set_error(Status::Error(400, "Message not found")); } @@ -26658,7 +26658,7 @@ void MessagesManager::edit_message_live_location(FullMessageId full_message_id, return promise.set_error(Status::Error(400, "There is no live location in the message to edit")); } if (m->message_id.is_scheduled()) { - LOG(ERROR) << "Have " << full_message_id << " with live location"; + LOG(ERROR) << "Have " << message_full_id << " with live location"; return promise.set_error(Status::Error(400, "Can't edit live location in scheduled message")); } @@ -26790,7 +26790,7 @@ void MessagesManager::on_message_media_edited(DialogId dialog_id, MessageId mess } } -void MessagesManager::edit_message_media(FullMessageId full_message_id, +void MessagesManager::edit_message_media(MessageFullId message_full_id, tl_object_ptr &&reply_markup, tl_object_ptr &&input_message_content, Promise &&promise) { @@ -26806,7 +26806,7 @@ void MessagesManager::edit_message_media(FullMessageId full_message_id, return promise.set_error(Status::Error(400, "Unsupported input message content type")); } - auto dialog_id = full_message_id.get_dialog_id(); + auto dialog_id = message_full_id.get_dialog_id(); Dialog *d = get_dialog_force(dialog_id, "edit_message_media"); if (d == nullptr) { return promise.set_error(Status::Error(400, "Chat not found")); @@ -26816,7 +26816,7 @@ void MessagesManager::edit_message_media(FullMessageId full_message_id, return promise.set_error(Status::Error(400, "Can't access the chat")); } - Message *m = get_message_force(d, full_message_id.get_message_id(), "edit_message_media"); + Message *m = get_message_force(d, message_full_id.get_message_id(), "edit_message_media"); if (m == nullptr) { return promise.set_error(Status::Error(400, "Message not found")); } @@ -26877,11 +26877,11 @@ void MessagesManager::edit_message_media(FullMessageId full_message_id, do_send_message(dialog_id, m); } -void MessagesManager::edit_message_caption(FullMessageId full_message_id, +void MessagesManager::edit_message_caption(MessageFullId message_full_id, tl_object_ptr &&reply_markup, tl_object_ptr &&input_caption, Promise &&promise) { - auto dialog_id = full_message_id.get_dialog_id(); + auto dialog_id = message_full_id.get_dialog_id(); Dialog *d = get_dialog_force(dialog_id, "edit_message_caption"); if (d == nullptr) { return promise.set_error(Status::Error(400, "Chat not found")); @@ -26891,7 +26891,7 @@ void MessagesManager::edit_message_caption(FullMessageId full_message_id, return promise.set_error(Status::Error(400, "Can't access the chat")); } - const Message *m = get_message_force(d, full_message_id.get_message_id(), "edit_message_caption"); + const Message *m = get_message_force(d, message_full_id.get_message_id(), "edit_message_caption"); if (m == nullptr) { return promise.set_error(Status::Error(400, "Message not found")); } @@ -26924,12 +26924,12 @@ void MessagesManager::edit_message_caption(FullMessageId full_message_id, nullptr, std::move(input_reply_markup), get_message_schedule_date(m)); } -void MessagesManager::edit_message_reply_markup(FullMessageId full_message_id, +void MessagesManager::edit_message_reply_markup(MessageFullId message_full_id, tl_object_ptr &&reply_markup, Promise &&promise) { CHECK(td_->auth_manager_->is_bot()); - auto dialog_id = full_message_id.get_dialog_id(); + auto dialog_id = message_full_id.get_dialog_id(); Dialog *d = get_dialog_force(dialog_id, "edit_message_reply_markup"); if (d == nullptr) { return promise.set_error(Status::Error(400, "Chat not found")); @@ -26939,7 +26939,7 @@ void MessagesManager::edit_message_reply_markup(FullMessageId full_message_id, return promise.set_error(Status::Error(400, "Can't access the chat")); } - const Message *m = get_message_force(d, full_message_id.get_message_id(), "edit_message_reply_markup"); + const Message *m = get_message_force(d, message_full_id.get_message_id(), "edit_message_reply_markup"); if (m == nullptr) { return promise.set_error(Status::Error(400, "Message not found")); } @@ -27136,7 +27136,7 @@ void MessagesManager::edit_inline_message_reply_markup(const string &inline_mess } void MessagesManager::edit_message_scheduling_state( - FullMessageId full_message_id, td_api::object_ptr &&scheduling_state, + MessageFullId message_full_id, td_api::object_ptr &&scheduling_state, Promise &&promise) { auto r_schedule_date = get_message_schedule_date(std::move(scheduling_state)); if (r_schedule_date.is_error()) { @@ -27144,7 +27144,7 @@ void MessagesManager::edit_message_scheduling_state( } auto schedule_date = r_schedule_date.move_as_ok(); - auto dialog_id = full_message_id.get_dialog_id(); + auto dialog_id = message_full_id.get_dialog_id(); Dialog *d = get_dialog_force(dialog_id, "edit_message_scheduling_state"); if (d == nullptr) { return promise.set_error(Status::Error(400, "Chat not found")); @@ -27154,7 +27154,7 @@ void MessagesManager::edit_message_scheduling_state( return promise.set_error(Status::Error(400, "Can't access the chat")); } - Message *m = get_message_force(d, full_message_id.get_message_id(), "edit_message_scheduling_state"); + Message *m = get_message_force(d, message_full_id.get_message_id(), "edit_message_scheduling_state"); if (m == nullptr) { return promise.set_error(Status::Error(400, "Message not found")); } @@ -27304,18 +27304,18 @@ void MessagesManager::update_message_max_reply_media_timestamp_in_replied_messag return; } - FullMessageId full_message_id{dialog_id, reply_to_message_id}; - auto it = message_to_replied_media_timestamp_messages_.find(full_message_id); + MessageFullId message_full_id{dialog_id, reply_to_message_id}; + auto it = message_to_replied_media_timestamp_messages_.find(message_full_id); if (it == message_to_replied_media_timestamp_messages_.end()) { return; } - LOG(INFO) << "Update max_reply_media_timestamp for replies of " << full_message_id; + LOG(INFO) << "Update max_reply_media_timestamp for replies of " << message_full_id; - for (auto replied_full_message_id : it->second) { - auto replied_dialog_id = replied_full_message_id.get_dialog_id(); + for (auto replied_message_full_id : it->second) { + auto replied_dialog_id = replied_message_full_id.get_dialog_id(); Dialog *d = get_dialog(replied_dialog_id); - auto m = get_message(d, replied_full_message_id.get_message_id()); + auto m = get_message(d, replied_message_full_id.get_message_id()); CHECK(m != nullptr); CHECK((m->reply_in_dialog_id.is_valid() ? m->reply_in_dialog_id : replied_dialog_id) == dialog_id); CHECK(m->reply_to_message_id == reply_to_message_id); @@ -27331,10 +27331,10 @@ void MessagesManager::update_story_max_reply_media_timestamp_in_replied_messages LOG(INFO) << "Update max_reply_media_timestamp for replies of " << story_full_id; - for (auto replied_full_message_id : it->second) { - auto replied_dialog_id = replied_full_message_id.get_dialog_id(); + for (auto replied_message_full_id : it->second) { + auto replied_dialog_id = replied_message_full_id.get_dialog_id(); Dialog *d = get_dialog(replied_dialog_id); - auto m = get_message(d, replied_full_message_id.get_message_id()); + auto m = get_message(d, replied_message_full_id.get_message_id()); CHECK(m != nullptr); CHECK(m->reply_to_story_full_id == story_full_id); update_message_max_reply_media_timestamp(d, m, true); @@ -27367,11 +27367,11 @@ void MessagesManager::register_message_reply(DialogId dialog_id, const Message * .second; CHECK(is_inserted); } else { - FullMessageId full_message_id{m->reply_in_dialog_id.is_valid() ? m->reply_in_dialog_id : dialog_id, + MessageFullId message_full_id{m->reply_in_dialog_id.is_valid() ? m->reply_in_dialog_id : dialog_id, m->reply_to_message_id}; - LOG(INFO) << "Register " << m->message_id << " in " << dialog_id << " as reply to " << full_message_id; + LOG(INFO) << "Register " << m->message_id << " in " << dialog_id << " as reply to " << message_full_id; bool is_inserted = - message_to_replied_media_timestamp_messages_[full_message_id].insert({dialog_id, m->message_id}).second; + message_to_replied_media_timestamp_messages_[message_full_id].insert({dialog_id, m->message_id}).second; CHECK(is_inserted); } } @@ -27388,9 +27388,9 @@ void MessagesManager::reregister_message_reply(DialogId dialog_id, const Message was_registered = it != story_to_replied_media_timestamp_messages_.end() && it->second.count({dialog_id, m->message_id}) > 0; } else { - FullMessageId full_message_id{m->reply_in_dialog_id.is_valid() ? m->reply_in_dialog_id : dialog_id, + MessageFullId message_full_id{m->reply_in_dialog_id.is_valid() ? m->reply_in_dialog_id : dialog_id, m->reply_to_message_id}; - auto it = message_to_replied_media_timestamp_messages_.find(full_message_id); + auto it = message_to_replied_media_timestamp_messages_.find(message_full_id); was_registered = it != message_to_replied_media_timestamp_messages_.end() && it->second.count({dialog_id, m->message_id}) > 0; } @@ -27426,16 +27426,16 @@ void MessagesManager::unregister_message_reply(DialogId dialog_id, const Message } } } else { - FullMessageId full_message_id{m->reply_in_dialog_id.is_valid() ? m->reply_in_dialog_id : dialog_id, + MessageFullId message_full_id{m->reply_in_dialog_id.is_valid() ? m->reply_in_dialog_id : dialog_id, m->reply_to_message_id}; - auto it = message_to_replied_media_timestamp_messages_.find(full_message_id); + auto it = message_to_replied_media_timestamp_messages_.find(message_full_id); if (it == message_to_replied_media_timestamp_messages_.end()) { return; } auto is_deleted = it->second.erase({dialog_id, m->message_id}) > 0; if (is_deleted) { - LOG(INFO) << "Unregister " << m->message_id << " in " << dialog_id << " as reply to " << full_message_id; + LOG(INFO) << "Unregister " << m->message_id << " in " << dialog_id << " as reply to " << message_full_id; if (it->second.empty()) { message_to_replied_media_timestamp_messages_.erase(it); } @@ -27489,8 +27489,8 @@ tl_object_ptr MessagesManager::get_send_message_as_inpu return get_input_peer(get_message_sender(m), AccessRights::Write); } -bool MessagesManager::can_set_game_score(FullMessageId full_message_id) const { - return can_set_game_score(full_message_id.get_dialog_id(), get_message(full_message_id)); +bool MessagesManager::can_set_game_score(MessageFullId message_full_id) const { + return can_set_game_score(message_full_id.get_dialog_id(), get_message(message_full_id)); } bool MessagesManager::can_set_game_score(DialogId dialog_id, const Message *m) const { @@ -27575,7 +27575,7 @@ bool MessagesManager::is_forward_info_sender_hidden(const MessageForwardInfo *fo } unique_ptr MessagesManager::get_message_forward_info( - tl_object_ptr &&forward_header, FullMessageId full_message_id) { + tl_object_ptr &&forward_header, MessageFullId message_full_id) { if (forward_header == nullptr) { return nullptr; } @@ -27644,7 +27644,7 @@ unique_ptr MessagesManager::get_message_for if (!td_->contacts_manager_->have_channel(channel_id)) { LOG(ERROR) << "Receive forward from " << (td_->contacts_manager_->have_min_channel(channel_id) ? "min" : "unknown") << ' ' << channel_id - << " in " << full_message_id; + << " in " << message_full_id; } force_create_dialog(sender_dialog_id, "message forward info", true); CHECK(!sender_user_id.is_valid()); @@ -28448,7 +28448,7 @@ Result> MessagesManager::resend_messages(DialogId dialog_id, v send_update_new_message(d, m); result[i] = m->message_id; - being_readded_message_id_ = FullMessageId(); + being_readded_message_id_ = MessageFullId(); } if (need_update_dialog_pos) { @@ -28505,7 +28505,7 @@ uint64 MessagesManager::save_send_screenshot_taken_notification_message_log_even } CHECK(m != nullptr); - LOG(INFO) << "Save " << FullMessageId(dialog_id, m->message_id) << " to binlog"; + LOG(INFO) << "Save " << MessageFullId(dialog_id, m->message_id) << " to binlog"; SendScreenshotTakenNotificationMessageLogEvent log_event; log_event.dialog_id = dialog_id; log_event.m_in = m; @@ -28515,7 +28515,7 @@ uint64 MessagesManager::save_send_screenshot_taken_notification_message_log_even void MessagesManager::do_send_screenshot_taken_notification_message(DialogId dialog_id, const Message *m, uint64 log_event_id) { - LOG(INFO) << "Do send screenshot taken notification " << FullMessageId(dialog_id, m->message_id); + LOG(INFO) << "Do send screenshot taken notification " << MessageFullId(dialog_id, m->message_id); CHECK(dialog_id.get_type() == DialogType::User); if (log_event_id == 0) { @@ -28527,9 +28527,9 @@ void MessagesManager::do_send_screenshot_taken_notification_message(DialogId dia ->send(dialog_id, random_id); } -void MessagesManager::share_dialog_with_bot(FullMessageId full_message_id, int32 button_id, DialogId shared_dialog_id, +void MessagesManager::share_dialog_with_bot(MessageFullId message_full_id, int32 button_id, DialogId shared_dialog_id, bool expect_user, bool only_check, Promise &&promise) { - const Message *m = get_message_force(full_message_id, "share_dialog_with_bot"); + const Message *m = get_message_force(message_full_id, "share_dialog_with_bot"); if (m == nullptr) { return promise.set_error(Status::Error(400, "Message not found")); } @@ -28556,7 +28556,7 @@ void MessagesManager::share_dialog_with_bot(FullMessageId full_message_id, int32 } td_->create_handler(std::move(promise)) - ->send(full_message_id, button_id, shared_dialog_id); + ->send(message_full_id, button_id, shared_dialog_id); } Result MessagesManager::add_local_message( @@ -28888,7 +28888,7 @@ bool MessagesManager::on_update_message_id(int64 random_id, MessageId new_messag if (new_message_id.is_scheduled()) { update_scheduled_message_ids_[dialog_id][new_message_id.get_scheduled_server_message_id()] = old_message_id; } else { - update_message_ids_[FullMessageId(dialog_id, new_message_id)] = old_message_id; + update_message_ids_[MessageFullId(dialog_id, new_message_id)] = old_message_id; } return true; } @@ -30203,7 +30203,7 @@ void MessagesManager::send_update_message_send_succeeded(const Dialog *d, Messag CHECK(m != nullptr); CHECK(d->is_update_new_chat_sent); if (!td_->auth_manager_->is_bot()) { - yet_unsent_full_message_id_to_persistent_message_id_.emplace({d->dialog_id, old_message_id}, m->message_id); + yet_unsent_message_full_id_to_persistent_message_id_.emplace({d->dialog_id, old_message_id}, m->message_id); } send_closure(G()->td(), &Td::send_update, td_api::make_object( @@ -30281,11 +30281,11 @@ void MessagesManager::send_update_message_unread_reactions(DialogId dialog_id, c get_unread_reactions_object(dialog_id, m), unread_reaction_count)); } -void MessagesManager::send_update_message_live_location_viewed(FullMessageId full_message_id) { - CHECK(get_message(full_message_id) != nullptr); +void MessagesManager::send_update_message_live_location_viewed(MessageFullId message_full_id) { + CHECK(get_message(message_full_id) != nullptr); send_closure(G()->td(), &Td::send_update, - td_api::make_object(full_message_id.get_dialog_id().get(), - full_message_id.get_message_id().get())); + td_api::make_object(message_full_id.get_dialog_id().get(), + message_full_id.get_message_id().get())); } void MessagesManager::send_update_delete_messages(DialogId dialog_id, vector &&message_ids, @@ -30859,7 +30859,7 @@ void MessagesManager::check_send_message_result(int64 random_id, DialogId dialog void MessagesManager::update_reply_to_message_id(DialogId dialog_id, MessageId old_message_id, MessageId new_message_id, bool have_new_message, const char *source) { - LOG(INFO) << "Update replies of " << FullMessageId{dialog_id, old_message_id} << " to " << new_message_id << " from " + LOG(INFO) << "Update replies of " << MessageFullId{dialog_id, old_message_id} << " to " << new_message_id << " from " << source; auto it = replied_yet_unsent_messages_.find({dialog_id, old_message_id}); if (it == replied_yet_unsent_messages_.end()) { @@ -30870,7 +30870,7 @@ void MessagesManager::update_reply_to_message_id(DialogId dialog_id, MessageId o Dialog *d = get_dialog(dialog_id); for (auto message_id : it->second) { CHECK(message_id.is_yet_unsent()); - FullMessageId full_message_id{dialog_id, message_id}; + MessageFullId message_full_id{dialog_id, message_id}; auto replied_m = get_message(d, message_id); CHECK(replied_m != nullptr); CHECK(replied_m->reply_to_message_id == old_message_id); @@ -30880,14 +30880,14 @@ void MessagesManager::update_reply_to_message_id(DialogId dialog_id, MessageId o } if (have_new_message) { CHECK(!new_message_id.is_yet_unsent()); - replied_by_yet_unsent_messages_[FullMessageId{dialog_id, new_message_id}] = static_cast(it->second.size()); + replied_by_yet_unsent_messages_[MessageFullId{dialog_id, new_message_id}] = static_cast(it->second.size()); } else { - replied_by_yet_unsent_messages_.erase(FullMessageId{dialog_id, new_message_id}); + replied_by_yet_unsent_messages_.erase(MessageFullId{dialog_id, new_message_id}); } replied_yet_unsent_messages_.erase(it); } -FullMessageId MessagesManager::on_send_message_success(int64 random_id, MessageId new_message_id, int32 date, +MessageFullId MessagesManager::on_send_message_success(int64 random_id, MessageId new_message_id, int32 date, int32 ttl_period, FileId new_file_id, const char *source) { CHECK(source != nullptr); // do not try to run getDifference from this function @@ -30937,7 +30937,7 @@ FullMessageId MessagesManager::on_send_message_success(int64 random_id, MessageI auto sent_message = delete_message(d, old_message_id, false, &need_update_dialog_pos, source); if (sent_message == nullptr) { delete_sent_message_on_server(dialog_id, new_message_id, old_message_id); - being_readded_message_id_ = FullMessageId(); + being_readded_message_id_ = MessageFullId(); return {}; } @@ -30986,14 +30986,14 @@ FullMessageId MessagesManager::on_send_message_success(int64 random_id, MessageI << " from " << source << ": " << debug_add_message_to_dialog_fail_reason_; } send_update_delete_messages(dialog_id, {new_message_id.get()}, true); - being_readded_message_id_ = FullMessageId(); + being_readded_message_id_ = MessageFullId(); return {}; } try_add_active_live_location(dialog_id, m); update_reply_count_by_message(d, +1, m); update_forward_count(dialog_id, m); - being_readded_message_id_ = FullMessageId(); + being_readded_message_id_ = MessageFullId(); return {dialog_id, new_message_id}; } @@ -31006,20 +31006,20 @@ void MessagesManager::on_send_message_file_parts_missing(int64 random_id, vector return; } - auto full_message_id = it->second; + auto message_full_id = it->second; being_sent_messages_.erase(it); - Message *m = get_message(full_message_id); + Message *m = get_message(message_full_id); if (m == nullptr) { // message has already been deleted by the user or sent to inaccessible channel // don't need to send error to the user, because the message has already been deleted // and there is nothing to be deleted from the server - LOG(INFO) << "Don't need to send already deleted by the user or sent to an inaccessible chat " << full_message_id; + LOG(INFO) << "Don't need to send already deleted by the user or sent to an inaccessible chat " << message_full_id; return; } - auto dialog_id = full_message_id.get_dialog_id(); + auto dialog_id = message_full_id.get_dialog_id(); if (dialog_id.get_type() == DialogType::SecretChat) { CHECK(!m->message_id.is_scheduled()); Dialog *d = get_dialog(dialog_id); @@ -31051,20 +31051,20 @@ void MessagesManager::on_send_message_file_reference_error(int64 random_id) { return; } - auto full_message_id = it->second; + auto message_full_id = it->second; being_sent_messages_.erase(it); - Message *m = get_message(full_message_id); + Message *m = get_message(message_full_id); if (m == nullptr) { // message has already been deleted by the user or sent to inaccessible channel // don't need to send error to the user, because the message has already been deleted // and there is nothing to be deleted from the server - LOG(INFO) << "Don't need to send already deleted by the user or sent to an inaccessible chat " << full_message_id; + LOG(INFO) << "Don't need to send already deleted by the user or sent to an inaccessible chat " << message_full_id; return; } - auto dialog_id = full_message_id.get_dialog_id(); + auto dialog_id = message_full_id.get_dialog_id(); if (dialog_id.get_type() == DialogType::SecretChat) { CHECK(!m->message_id.is_scheduled()); Dialog *d = get_dialog(dialog_id); @@ -31100,16 +31100,16 @@ void MessagesManager::on_send_media_group_file_reference_error(DialogId dialog_i continue; } - auto full_message_id = it->second; + auto message_full_id = it->second; being_sent_messages_.erase(it); - Message *m = get_message(full_message_id); + Message *m = get_message(message_full_id); if (m == nullptr) { // message has already been deleted by the user or sent to inaccessible channel // don't need to send error to the user, because the message has already been deleted // and there is nothing to be deleted from the server - LOG(INFO) << "Don't need to send already deleted by the user or sent to an inaccessible chat " << full_message_id; + LOG(INFO) << "Don't need to send already deleted by the user or sent to an inaccessible chat " << message_full_id; continue; } @@ -31117,7 +31117,7 @@ void MessagesManager::on_send_media_group_file_reference_error(DialogId dialog_i CHECK(media_album_id == 0 || media_album_id == m->media_album_id); media_album_id = m->media_album_id; - CHECK(dialog_id == full_message_id.get_dialog_id()); + CHECK(dialog_id == message_full_id.get_dialog_id()); message_ids.push_back(m->message_id); messages.push_back(m); } @@ -31158,22 +31158,22 @@ void MessagesManager::on_send_message_fail(int64 random_id, Status error) { return; } - auto full_message_id = it->second; + auto message_full_id = it->second; being_sent_messages_.erase(it); - Message *m = get_message(full_message_id); + Message *m = get_message(message_full_id); if (m == nullptr) { // message has already been deleted by the user or sent to inaccessible channel // don't need to send error to the user, because the message has already been deleted // and there is nothing to be deleted from the server - LOG(INFO) << "Don't need to send already deleted by the user or sent to an inaccessible chat " << full_message_id; + LOG(INFO) << "Don't need to send already deleted by the user or sent to an inaccessible chat " << message_full_id; return; } LOG_IF(ERROR, error.code() == NetQuery::Canceled) << "Receive error " << error << " about sent message with random_id = " << random_id; - auto dialog_id = full_message_id.get_dialog_id(); + auto dialog_id = message_full_id.get_dialog_id(); int error_code = error.code(); string error_message = error.message().str(); switch (error_code) { @@ -31293,14 +31293,14 @@ void MessagesManager::on_send_message_fail(int64 random_id, Status error) { LOG(ERROR) << "Receive " << error.message() << " for " << oneline(to_string(get_message_object(dialog_id, m, "on_send_message_fail"))); } else { - LOG(ERROR) << "Receive " << error.message() << " for " << full_message_id << " with keyboard " + LOG(ERROR) << "Receive " << error.message() << " for " << message_full_id << " with keyboard " << *m->reply_markup; } } if (error_code != 403 && !(error_code == 500 && G()->close_flag())) { - LOG(WARNING) << "Failed to send " << full_message_id << " with the error " << error; + LOG(WARNING) << "Failed to send " << message_full_id << " with the error " << error; } - fail_send_message(full_message_id, error_code, error_message); + fail_send_message(message_full_id, error_code, error_message); } MessageId MessagesManager::get_next_message_id(Dialog *d, MessageType type) const { @@ -31361,28 +31361,28 @@ MessageId MessagesManager::get_next_yet_unsent_scheduled_message_id(Dialog *d, i return last_assigned_message_id; } -void MessagesManager::fail_send_message(FullMessageId full_message_id, int32 error_code, const string &error_message) { +void MessagesManager::fail_send_message(MessageFullId message_full_id, int32 error_code, const string &error_message) { if (error_code <= 0) { error_code = 500; } - auto dialog_id = full_message_id.get_dialog_id(); + auto dialog_id = message_full_id.get_dialog_id(); Dialog *d = get_dialog(dialog_id); CHECK(d != nullptr); - MessageId old_message_id = full_message_id.get_message_id(); + MessageId old_message_id = message_full_id.get_message_id(); CHECK(old_message_id.is_valid() || old_message_id.is_valid_scheduled()); CHECK(old_message_id.is_yet_unsent()); update_reply_to_message_id(dialog_id, old_message_id, MessageId(), false, "fail_send_message"); bool need_update_dialog_pos = false; - being_readded_message_id_ = full_message_id; + being_readded_message_id_ = message_full_id; auto message = delete_message(d, old_message_id, false, &need_update_dialog_pos, "fail send message"); if (message == nullptr) { // message has already been deleted by the user or sent to inaccessible channel // don't need to send update to the user, because the message has already been deleted // and there is nothing to be deleted from the server - being_readded_message_id_ = FullMessageId(); + being_readded_message_id_ = MessageFullId(); return; } @@ -31432,9 +31432,9 @@ void MessagesManager::fail_send_message(FullMessageId full_message_id, int32 err } register_new_local_message_id(d, m); - LOG(INFO) << "Send updateMessageSendFailed for " << full_message_id; + LOG(INFO) << "Send updateMessageSendFailed for " << message_full_id; if (!td_->auth_manager_->is_bot()) { - yet_unsent_full_message_id_to_persistent_message_id_.emplace({dialog_id, old_message_id}, m->message_id); + yet_unsent_message_full_id_to_persistent_message_id_.emplace({dialog_id, old_message_id}, m->message_id); } send_closure(G()->td(), &Td::send_update, td_api::make_object( @@ -31443,18 +31443,18 @@ void MessagesManager::fail_send_message(FullMessageId full_message_id, int32 err if (need_update_dialog_pos) { send_update_chat_last_message(d, "fail_send_message"); } - being_readded_message_id_ = FullMessageId(); + being_readded_message_id_ = MessageFullId(); } -void MessagesManager::fail_send_message(FullMessageId full_message_id, Status error) { - fail_send_message(full_message_id, error.code(), error.message().str()); +void MessagesManager::fail_send_message(MessageFullId message_full_id, Status error) { + fail_send_message(message_full_id, error.code(), error.message().str()); } -void MessagesManager::fail_edit_message_media(FullMessageId full_message_id, Status &&error) { - auto dialog_id = full_message_id.get_dialog_id(); +void MessagesManager::fail_edit_message_media(MessageFullId message_full_id, Status &&error) { + auto dialog_id = message_full_id.get_dialog_id(); Dialog *d = get_dialog(dialog_id); CHECK(d != nullptr); - MessageId message_id = full_message_id.get_message_id(); + MessageId message_id = message_full_id.get_message_id(); CHECK(message_id.is_any_server()); auto m = get_message(d, message_id); @@ -34240,7 +34240,7 @@ MessagesManager::Message *MessagesManager::get_message_force(Dialog *d, MessageI return nullptr; } - LOG(INFO) << "Trying to load " << FullMessageId{d->dialog_id, message_id} << " from database from " << source; + LOG(INFO) << "Trying to load " << MessageFullId{d->dialog_id, message_id} << " from database from " << source; auto r_value = G()->td_db()->get_message_db_sync()->get_message({d->dialog_id, message_id}); if (r_value.is_error()) { @@ -34849,9 +34849,9 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq Message *top_m = get_message(d, message->top_thread_message_id); CHECK(top_m != nullptr); if (is_active_message_reply_info(dialog_id, top_m->reply_info) && is_discussion_message(dialog_id, top_m)) { - FullMessageId top_full_message_id{top_m->forward_info->from_dialog_id, top_m->forward_info->from_message_id}; - if (have_message_force(top_full_message_id, "preload discussed message")) { - LOG(INFO) << "Preloaded discussed " << top_full_message_id << " from database"; + MessageFullId top_message_full_id{top_m->forward_info->from_dialog_id, top_m->forward_info->from_message_id}; + if (have_message_force(top_message_full_id, "preload discussed message")) { + LOG(INFO) << "Preloaded discussed " << top_message_full_id << " from database"; } } } @@ -34982,10 +34982,10 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq CHECK(m->reply_in_dialog_id == DialogId()); if (!m->reply_to_message_id.is_yet_unsent()) { if (!m->reply_to_message_id.is_scheduled()) { - replied_by_yet_unsent_messages_[FullMessageId{dialog_id, m->reply_to_message_id}]++; + replied_by_yet_unsent_messages_[MessageFullId{dialog_id, m->reply_to_message_id}]++; } } else { - replied_yet_unsent_messages_[FullMessageId{dialog_id, m->reply_to_message_id}].insert(m->message_id); + replied_yet_unsent_messages_[MessageFullId{dialog_id, m->reply_to_message_id}].insert(m->message_id); } } @@ -35097,7 +35097,7 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq if (m->message_id.is_yet_unsent() && !m->message_id.is_scheduled() && m->top_thread_message_id.is_valid() && !td_->auth_manager_->is_bot()) { auto is_inserted = - yet_unsent_thread_message_ids_[FullMessageId{dialog_id, m->top_thread_message_id}].insert(m->message_id).second; + yet_unsent_thread_message_ids_[MessageFullId{dialog_id, m->top_thread_message_id}].insert(m->message_id).second; CHECK(is_inserted); } @@ -35236,10 +35236,10 @@ MessagesManager::Message *MessagesManager::add_scheduled_message_to_dialog(Dialo CHECK(m->reply_in_dialog_id == DialogId()); if (!m->reply_to_message_id.is_yet_unsent()) { if (!m->reply_to_message_id.is_scheduled()) { - replied_by_yet_unsent_messages_[FullMessageId{dialog_id, m->reply_to_message_id}]++; + replied_by_yet_unsent_messages_[MessageFullId{dialog_id, m->reply_to_message_id}]++; } } else { - replied_yet_unsent_messages_[FullMessageId{dialog_id, m->reply_to_message_id}].insert(m->message_id); + replied_yet_unsent_messages_[MessageFullId{dialog_id, m->reply_to_message_id}].insert(m->message_id); } } @@ -35285,7 +35285,7 @@ MessagesManager::Message *MessagesManager::add_scheduled_message_to_dialog(Dialo auto is_inserted = scheduled_messages->scheduled_messages_.emplace(result_message->message_id, std::move(message)).second; CHECK(is_inserted); - being_readded_message_id_ = FullMessageId(); + being_readded_message_id_ = MessageFullId(); return result_message; } @@ -35367,7 +35367,7 @@ void MessagesManager::add_message_to_database(const Dialog *d, const Message *m, MessageId message_id = m->message_id; if (message_id.is_scheduled()) { - LOG(INFO) << "Add " << FullMessageId(d->dialog_id, message_id) << " to database from " << source; + LOG(INFO) << "Add " << MessageFullId(d->dialog_id, message_id) << " to database from " << source; set_dialog_has_scheduled_database_messages(d->dialog_id, true); G()->td_db()->get_message_db_async()->add_scheduled_message({d->dialog_id, message_id}, log_event_store(*m), @@ -35376,7 +35376,7 @@ void MessagesManager::add_message_to_database(const Dialog *d, const Message *m, } LOG_CHECK(message_id.is_server() || message_id.is_local()) << source; - LOG(INFO) << "Add " << FullMessageId(d->dialog_id, message_id) << " to database from " << source; + LOG(INFO) << "Add " << MessageFullId(d->dialog_id, message_id) << " to database from " << source; ServerMessageId unique_message_id; int64 random_id = 0; @@ -35472,7 +35472,7 @@ void MessagesManager::delete_all_dialog_messages_from_database(Dialog *d, Messag class MessagesManager::DeleteMessageLogEvent { public: LogEvent::Id id_{0}; - FullMessageId full_message_id_; + MessageFullId message_full_id_; std::vector file_ids_; template @@ -35482,7 +35482,7 @@ class MessagesManager::DeleteMessageLogEvent { STORE_FLAG(has_file_ids); END_STORE_FLAGS(); - td::store(full_message_id_, storer); + td::store(message_full_id_, storer); if (has_file_ids) { td::store(file_ids_, storer); } @@ -35495,7 +35495,7 @@ class MessagesManager::DeleteMessageLogEvent { PARSE_FLAG(has_file_ids); END_PARSE_FLAGS(); - td::parse(full_message_id_, parser); + td::parse(message_full_id_, parser); if (has_file_ids) { td::parse(file_ids_, parser); } @@ -35510,17 +35510,17 @@ void MessagesManager::delete_message_files(DialogId dialog_id, const Message *m) } } -bool MessagesManager::need_delete_file(FullMessageId full_message_id, FileId file_id) const { - if (being_readded_message_id_ == full_message_id || td_->auth_manager_->is_bot()) { +bool MessagesManager::need_delete_file(MessageFullId message_full_id, FileId file_id) const { + if (being_readded_message_id_ == message_full_id || td_->auth_manager_->is_bot()) { return false; } auto main_file_id = td_->file_manager_->get_file_view(file_id).get_main_file_id(); - auto full_message_ids = td_->file_reference_manager_->get_some_message_file_sources(main_file_id); - LOG(INFO) << "Receive " << full_message_ids << " as sources for file " << main_file_id << "/" << file_id << " from " - << full_message_id; - for (const auto &other_full_messsage_id : full_message_ids) { - if (other_full_messsage_id != full_message_id) { + auto message_full_ids = td_->file_reference_manager_->get_some_message_file_sources(main_file_id); + LOG(INFO) << "Receive " << message_full_ids << " as sources for file " << main_file_id << "/" << file_id << " from " + << message_full_id; + for (const auto &other_full_messsage_id : message_full_ids) { + if (other_full_messsage_id != message_full_id) { return false; } } @@ -35537,7 +35537,7 @@ bool MessagesManager::need_delete_message_files(DialogId dialog_id, const Messag if (!m->message_id.is_scheduled() && !m->message_id.is_server() && dialog_type != DialogType::SecretChat) { return false; } - if (being_readded_message_id_ == FullMessageId{dialog_id, m->message_id}) { + if (being_readded_message_id_ == MessageFullId{dialog_id, m->message_id}) { return false; } @@ -35597,7 +35597,7 @@ void MessagesManager::delete_message_from_database(Dialog *d, MessageId message_ auto old_message_id = find_old_message_id(d->dialog_id, message_id); if (old_message_id.is_valid()) { bool have_old_message = get_message(d, old_message_id) != nullptr; - LOG(WARNING) << "Sent " << FullMessageId{d->dialog_id, message_id} + LOG(WARNING) << "Sent " << MessageFullId{d->dialog_id, message_id} << " was deleted before it was received. Have old " << old_message_id << " = " << have_old_message; send_closure_later(actor_id(this), &MessagesManager::delete_messages, d->dialog_id, vector{old_message_id}, false, Promise()); @@ -35639,7 +35639,7 @@ void MessagesManager::delete_message_from_database(Dialog *d, MessageId message_ if (G()->use_message_database()) { DeleteMessageLogEvent log_event; - log_event.full_message_id_ = {d->dialog_id, message_id}; + log_event.message_full_id_ = {d->dialog_id, message_id}; if (need_delete_files) { log_event.file_ids_ = get_message_file_ids(m); @@ -35680,7 +35680,7 @@ void MessagesManager::do_delete_message_log_event(const DeleteMessageLogEvent &l auto lock = mpas.get_promise(); for (auto file_id : log_event.file_ids_) { - if (need_delete_file(log_event.full_message_id_, file_id)) { + if (need_delete_file(log_event.message_full_id_, file_id)) { send_closure(G()->file_manager(), &FileManager::delete_file, file_id, mpas.get_promise(), "do_delete_message_log_event"); } @@ -35690,8 +35690,8 @@ void MessagesManager::do_delete_message_log_event(const DeleteMessageLogEvent &l } // message may not exist in the dialog - LOG(INFO) << "Delete " << log_event.full_message_id_ << " from database"; - G()->td_db()->get_message_db_async()->delete_message(log_event.full_message_id_, std::move(db_promise)); + LOG(INFO) << "Delete " << log_event.message_full_id_ << " from database"; + G()->td_db()->get_message_db_async()->delete_message(log_event.message_full_id_, std::move(db_promise)); } bool MessagesManager::update_message(Dialog *d, Message *old_message, unique_ptr new_message, @@ -35895,7 +35895,7 @@ bool MessagesManager::update_message(Dialog *d, Message *old_message, unique_ptr is_is_topic_message_changed || old_message->reply_to_story_full_id != new_message->reply_to_story_full_id) { if (!replace_legacy && is_new_available) { if (old_message->reply_to_message_id != new_message->reply_to_message_id) { - LOG(INFO) << "Update replied message of " << FullMessageId{dialog_id, message_id} << " from " + LOG(INFO) << "Update replied message of " << MessageFullId{dialog_id, message_id} << " from " << old_message->reply_to_message_id << " to " << new_message->reply_to_message_id; if (message_id.is_yet_unsent() && new_message->reply_to_message_id == MessageId() && old_message->reply_in_dialog_id == DialogId() && is_deleted_message(d, old_message->reply_to_message_id) && @@ -35935,7 +35935,7 @@ bool MessagesManager::update_message(Dialog *d, Message *old_message, unique_ptr << old_message->top_thread_message_id << " to " << new_message->top_thread_message_id << ", message content type is " << old_content_type << '/' << new_content_type; } else { - LOG(INFO) << "Update message thread of " << FullMessageId{dialog_id, message_id} << " from " + LOG(INFO) << "Update message thread of " << MessageFullId{dialog_id, message_id} << " from " << old_message->top_thread_message_id << " to " << new_message->top_thread_message_id; } } @@ -35944,7 +35944,7 @@ bool MessagesManager::update_message(Dialog *d, Message *old_message, unique_ptr LOG(ERROR) << message_id << " in " << dialog_id << " has changed is_topic_message to " << new_message->is_topic_message; } else { - LOG(INFO) << "Update is_topic_message of " << FullMessageId{dialog_id, message_id} << " from " + LOG(INFO) << "Update is_topic_message of " << MessageFullId{dialog_id, message_id} << " from " << old_message->is_topic_message << " to " << new_message->is_topic_message; } } @@ -35954,7 +35954,7 @@ bool MessagesManager::update_message(Dialog *d, Message *old_message, unique_ptr << old_message->reply_to_story_full_id << " to " << new_message->reply_to_story_full_id << ", message content type is " << old_content_type << '/' << new_content_type; } else { - LOG(INFO) << "Update replied story of " << FullMessageId{dialog_id, message_id} << " from " + LOG(INFO) << "Update replied story of " << MessageFullId{dialog_id, message_id} << " from " << old_message->reply_to_story_full_id << " to " << new_message->reply_to_story_full_id; } } @@ -36297,7 +36297,7 @@ bool MessagesManager::update_message_content(DialogId dialog_id, Message *old_me if (need_update) { auto file_ids = get_message_content_file_ids(old_content.get(), td_); if (!file_ids.empty()) { - auto file_source_id = get_message_file_source_id(FullMessageId(dialog_id, old_message->message_id)); + auto file_source_id = get_message_file_source_id(MessageFullId(dialog_id, old_message->message_id)); if (file_source_id.is_valid()) { auto search_text = get_message_search_text(old_message); for (auto file_id : file_ids) { @@ -36365,7 +36365,7 @@ MessageId MessagesManager::get_message_id_by_random_id(Dialog *d, int64 random_i << source << " " << random_id << " " << d->random_id_to_message_id[random_id] << " " << m->message_id << " " << m->is_failed_to_send << " " << m->is_outgoing << " " << get_message(d, m->message_id) << " " << m << " " << debug_add_message_to_dialog_fail_reason_; - LOG(INFO) << "Found " << FullMessageId{d->dialog_id, m->message_id} << " by random_id " << random_id + LOG(INFO) << "Found " << MessageFullId{d->dialog_id, m->message_id} << " by random_id " << random_id << " from " << source; return m->message_id; } @@ -36376,7 +36376,7 @@ MessageId MessagesManager::get_message_id_by_random_id(Dialog *d, int64 random_i return MessageId(); } - LOG(INFO) << "Found " << FullMessageId{d->dialog_id, it->second} << " by random_id " << random_id << " from " + LOG(INFO) << "Found " << MessageFullId{d->dialog_id, it->second} << " by random_id " << random_id << " from " << source; return it->second; } @@ -38320,11 +38320,11 @@ void MessagesManager::process_get_channel_difference_updates( } case telegram_api::updateEditChannelMessage::ID: { auto *update = static_cast(update_ptr.get()); - auto full_message_id = FullMessageId::get_full_message_id(update->message_, false); - if (full_message_id.get_dialog_id() != dialog_id) { + auto message_full_id = MessageFullId::get_message_full_id(update->message_, false); + if (message_full_id.get_dialog_id() != dialog_id) { is_good_update = false; } else { - changed_message_ids.insert(full_message_id.get_message_id()); + changed_message_ids.insert(message_full_id.get_message_id()); } break; } @@ -38384,8 +38384,8 @@ void MessagesManager::process_get_channel_difference_updates( if (update->get_id() == telegram_api::updateNewChannelMessage::ID) { auto update_new_channel_message = static_cast(update.get()); auto message_id = MessageId::get_message_id(update_new_channel_message->message_, false); - FullMessageId full_message_id(dialog_id, message_id); - if (update_message_ids_.count(full_message_id) > 0 && changed_message_ids.count(message_id) > 0) { + MessageFullId message_full_id(dialog_id, message_id); + if (update_message_ids_.count(message_full_id) > 0 && changed_message_ids.count(message_id) > 0) { changed_message_ids.erase(message_id); AwaitedMessage awaited_message; awaited_message.message = std::move(update_new_channel_message->message_); @@ -38456,7 +38456,7 @@ void MessagesManager::on_get_channel_dialog(DialogId dialog_id, MessageId last_m int32 unread_mention_count, int32 unread_reaction_count, MessageId read_outbox_max_message_id, vector> &&messages) { - FlatHashMap, FullMessageIdHash> full_message_id_to_message; + FlatHashMap, MessageFullIdHash> message_full_id_to_message; for (auto &message : messages) { auto message_id = MessageId::get_message_id(message, false); if (!message_id.is_valid()) { @@ -38466,15 +38466,15 @@ void MessagesManager::on_get_channel_dialog(DialogId dialog_id, MessageId last_m if (!message_dialog_id.is_valid()) { message_dialog_id = dialog_id; } - auto full_message_id = FullMessageId(message_dialog_id, message_id); - full_message_id_to_message[full_message_id] = std::move(message); + auto message_full_id = MessageFullId(message_dialog_id, message_id); + message_full_id_to_message[message_full_id] = std::move(message); } - FullMessageId last_full_message_id(dialog_id, last_message_id); + MessageFullId last_message_full_id(dialog_id, last_message_id); if (last_message_id.is_valid()) { - if (full_message_id_to_message.count(last_full_message_id) == 0) { + if (message_full_id_to_message.count(last_message_full_id) == 0) { LOG(ERROR) << "Last " << last_message_id << " in " << dialog_id << " not found. Have:"; - for (auto &message : full_message_id_to_message) { + for (auto &message : message_full_id_to_message) { LOG(ERROR) << to_string(message.second); } return; @@ -38535,19 +38535,19 @@ void MessagesManager::on_get_channel_dialog(DialogId dialog_id, MessageId last_m d->last_new_message_id = MessageId(); set_dialog_last_message_id(d, MessageId(), "on_get_channel_dialog 20"); send_update_chat_last_message(d, "on_get_channel_dialog 30"); - FullMessageId added_full_message_id; - if (last_full_message_id.get_message_id().is_valid()) { - last_full_message_id = on_get_message(std::move(full_message_id_to_message[last_full_message_id]), true, true, + MessageFullId added_message_full_id; + if (last_message_full_id.get_message_id().is_valid()) { + last_message_full_id = on_get_message(std::move(message_full_id_to_message[last_message_full_id]), true, true, false, "channel difference too long"); } - if (added_full_message_id.get_message_id().is_valid()) { - if (added_full_message_id.get_message_id() == d->last_new_message_id) { - CHECK(last_full_message_id == added_full_message_id); + if (added_message_full_id.get_message_id().is_valid()) { + if (added_message_full_id.get_message_id() == d->last_new_message_id) { + CHECK(last_message_full_id == added_message_full_id); if (!td_->auth_manager_->is_bot()) { CHECK(d->last_message_id == d->last_new_message_id); } } else { - LOG(ERROR) << added_full_message_id << " doesn't became last new message, which is " << d->last_new_message_id; + LOG(ERROR) << added_message_full_id << " doesn't became last new message, which is " << d->last_new_message_id; } } else if (last_message_id > d->last_new_message_id) { set_dialog_last_new_message_id(d, last_message_id, @@ -38967,9 +38967,9 @@ void MessagesManager::reget_message_from_server_if_needed(DialogId dialog_id, co if (need_reget_message_content(m->content.get()) || (m->legacy_layer != 0 && m->legacy_layer < MTPROTO_LAYER) || m->reply_info.need_reget(td_)) { - FullMessageId full_message_id{dialog_id, m->message_id}; - LOG(INFO) << "Reget from server " << full_message_id; - get_message_from_server(full_message_id, Auto(), "reget_message_from_server_if_needed"); + MessageFullId message_full_id{dialog_id, m->message_id}; + LOG(INFO) << "Reget from server " << message_full_id; + get_message_from_server(message_full_id, Auto(), "reget_message_from_server_if_needed"); } } @@ -39171,7 +39171,7 @@ void MessagesManager::update_has_outgoing_messages(DialogId dialog_id, const Mes void MessagesManager::set_message_reply(const Dialog *d, Message *m, MessageId reply_to_message_id, bool is_message_in_dialog) { - LOG(INFO) << "Update replied message of " << FullMessageId{d->dialog_id, m->message_id} << " from " + LOG(INFO) << "Update replied message of " << MessageFullId{d->dialog_id, m->message_id} << " from " << m->reply_to_message_id << " to " << reply_to_message_id; if (is_message_in_dialog) { unregister_message_reply(d->dialog_id, m); @@ -39515,9 +39515,9 @@ void MessagesManager::on_binlog_events(vector &&events) { log_event_parse(log_event, event.get_data()).ensure(); log_event.id_ = event.id_; - Dialog *d = get_dialog_force(log_event.full_message_id_.get_dialog_id(), "DeleteMessageLogEvent"); + Dialog *d = get_dialog_force(log_event.message_full_id_.get_dialog_id(), "DeleteMessageLogEvent"); if (d != nullptr) { - auto message_id = log_event.full_message_id_.get_message_id(); + auto message_id = log_event.message_full_id_.get_message_id(); if (message_id.is_valid_scheduled() && message_id.is_scheduled_server()) { add_dialog_scheduled_messages(d)->deleted_scheduled_server_message_ids_.insert( message_id.get_scheduled_server_message_id()); @@ -40180,13 +40180,13 @@ void MessagesManager::suffix_load_till_message_id(Dialog *d, MessageId message_i suffix_load_add_query(d, std::make_pair(std::move(promise), std::move(condition))); } -void MessagesManager::set_poll_answer(FullMessageId full_message_id, vector &&option_ids, +void MessagesManager::set_poll_answer(MessageFullId message_full_id, vector &&option_ids, Promise &&promise) { - auto m = get_message_force(full_message_id, "set_poll_answer"); + auto m = get_message_force(message_full_id, "set_poll_answer"); if (m == nullptr) { return promise.set_error(Status::Error(400, "Message not found")); } - if (!have_input_peer(full_message_id.get_dialog_id(), AccessRights::Read)) { + if (!have_input_peer(message_full_id.get_dialog_id(), AccessRights::Read)) { return promise.set_error(Status::Error(400, "Can't access the chat")); } if (m->content->get_type() != MessageContentType::Poll) { @@ -40199,16 +40199,16 @@ void MessagesManager::set_poll_answer(FullMessageId full_message_id, vectorcontent.get(), full_message_id, std::move(option_ids), std::move(promise)); + set_message_content_poll_answer(td_, m->content.get(), message_full_id, std::move(option_ids), std::move(promise)); } -void MessagesManager::get_poll_voters(FullMessageId full_message_id, int32 option_id, int32 offset, int32 limit, +void MessagesManager::get_poll_voters(MessageFullId message_full_id, int32 option_id, int32 offset, int32 limit, Promise> &&promise) { - auto m = get_message_force(full_message_id, "get_poll_voters"); + auto m = get_message_force(message_full_id, "get_poll_voters"); if (m == nullptr) { return promise.set_error(Status::Error(400, "Message not found")); } - if (!have_input_peer(full_message_id.get_dialog_id(), AccessRights::Read)) { + if (!have_input_peer(message_full_id.get_dialog_id(), AccessRights::Read)) { return promise.set_error(Status::Error(400, "Can't access the chat")); } if (m->content->get_type() != MessageContentType::Poll) { @@ -40221,16 +40221,16 @@ void MessagesManager::get_poll_voters(FullMessageId full_message_id, int32 optio return promise.set_error(Status::Error(400, "Poll results can't be received")); } - get_message_content_poll_voters(td_, m->content.get(), full_message_id, option_id, offset, limit, std::move(promise)); + get_message_content_poll_voters(td_, m->content.get(), message_full_id, option_id, offset, limit, std::move(promise)); } -void MessagesManager::stop_poll(FullMessageId full_message_id, td_api::object_ptr &&reply_markup, +void MessagesManager::stop_poll(MessageFullId message_full_id, td_api::object_ptr &&reply_markup, Promise &&promise) { - auto m = get_message_force(full_message_id, "stop_poll"); + auto m = get_message_force(message_full_id, "stop_poll"); if (m == nullptr) { return promise.set_error(Status::Error(400, "Message not found")); } - if (!have_input_peer(full_message_id.get_dialog_id(), AccessRights::Read)) { + if (!have_input_peer(message_full_id.get_dialog_id(), AccessRights::Read)) { return promise.set_error(Status::Error(400, "Can't access the chat")); } if (m->content->get_type() != MessageContentType::Poll) { @@ -40239,7 +40239,7 @@ void MessagesManager::stop_poll(FullMessageId full_message_id, td_api::object_pt if (get_message_content_poll_is_closed(td_, m->content.get())) { return promise.set_error(Status::Error(400, "Poll has already been closed")); } - if (!can_edit_message(full_message_id.get_dialog_id(), m, true)) { + if (!can_edit_message(message_full_id.get_dialog_id(), m, true)) { return promise.set_error(Status::Error(400, "Poll can't be stopped")); } if (m->message_id.is_scheduled()) { @@ -40250,17 +40250,17 @@ void MessagesManager::stop_poll(FullMessageId full_message_id, td_api::object_pt } auto r_new_reply_markup = get_reply_markup(std::move(reply_markup), td_->auth_manager_->is_bot(), true, false, - has_message_sender_user_id(full_message_id.get_dialog_id(), m)); + has_message_sender_user_id(message_full_id.get_dialog_id(), m)); if (r_new_reply_markup.is_error()) { return promise.set_error(r_new_reply_markup.move_as_error()); } - stop_message_content_poll(td_, m->content.get(), full_message_id, r_new_reply_markup.move_as_ok(), + stop_message_content_poll(td_, m->content.get(), message_full_id, r_new_reply_markup.move_as_ok(), std::move(promise)); } -Result MessagesManager::get_invoice_message_id(FullMessageId full_message_id) { - auto m = get_message_force(full_message_id, "get_invoice_message_id"); +Result MessagesManager::get_invoice_message_id(MessageFullId message_full_id) { + auto m = get_message_force(message_full_id, "get_invoice_message_id"); if (m == nullptr) { return Status::Error(400, "Message not found"); } @@ -40282,8 +40282,8 @@ Result MessagesManager::get_invoice_message_id(FullMessageId fu return m->message_id.get_server_message_id(); } -Result MessagesManager::get_payment_successful_message_id(FullMessageId full_message_id) { - auto m = get_message_force(full_message_id, "get_payment_successful_message_id"); +Result MessagesManager::get_payment_successful_message_id(MessageFullId message_full_id) { + auto m = get_message_force(message_full_id, "get_payment_successful_message_id"); if (m == nullptr) { return Status::Error(400, "Message not found"); } @@ -40477,9 +40477,9 @@ void MessagesManager::get_current_state(vector> promise) { - auto m = get_message_force(full_message_id, "add_message_file_to_downloads"); + auto m = get_message_force(message_full_id, "add_message_file_to_downloads"); if (m == nullptr) { return promise.set_error(Status::Error(400, "Message not found")); } @@ -40503,15 +40503,15 @@ void MessagesManager::add_message_file_to_downloads(FullMessageId full_message_i return promise.set_error(Status::Error(400, "Yet unsent messages can't be added to Downloads")); } auto search_text = get_message_search_text(m); - auto file_source_id = get_message_file_source_id(full_message_id, true); + auto file_source_id = get_message_file_source_id(message_full_id, true); CHECK(file_source_id.is_valid()); send_closure(td_->download_manager_actor_, &DownloadManager::add_file, file_id, file_source_id, std::move(search_text), static_cast(priority), std::move(promise)); } -void MessagesManager::get_message_file_search_text(FullMessageId full_message_id, string unique_file_id, +void MessagesManager::get_message_file_search_text(MessageFullId message_full_id, string unique_file_id, Promise promise) { - auto m = get_message_force(full_message_id, "get_message_file_search_text"); + auto m = get_message_force(message_full_id, "get_message_file_search_text"); if (m == nullptr) { return promise.set_error(Status::Error(200, "Message not found")); } diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index b06e231a4..367fa5d02 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -26,13 +26,13 @@ #include "td/telegram/files/FileId.h" #include "td/telegram/files/FileSourceId.h" #include "td/telegram/FolderId.h" -#include "td/telegram/FullMessageId.h" #include "td/telegram/InputDialogId.h" #include "td/telegram/InputGroupCallId.h" #include "td/telegram/logevent/LogEventHelper.h" #include "td/telegram/MessageContentType.h" #include "td/telegram/MessageCopyOptions.h" #include "td/telegram/MessageDb.h" +#include "td/telegram/MessageFullId.h" #include "td/telegram/MessageId.h" #include "td/telegram/MessageInputReplyTo.h" #include "td/telegram/MessageLinkInfo.h" @@ -249,7 +249,7 @@ class MessagesManager final : public Actor { int32 next_rate, Promise> &&promise); // if message is from_update, flags have_previous and have_next are ignored and must be both true - FullMessageId on_get_message(tl_object_ptr message_ptr, bool from_update, + MessageFullId on_get_message(tl_object_ptr message_ptr, bool from_update, bool is_channel_message, bool is_scheduled, const char *source); void open_secret_message(SecretChatId secret_chat_id, int64 random_id, Promise); @@ -280,7 +280,7 @@ class MessagesManager final : public Actor { void on_update_sent_text_message(int64 random_id, tl_object_ptr message_media, vector> &&entities); - void delete_pending_message_web_page(FullMessageId full_message_id); + void delete_pending_message_web_page(MessageFullId message_full_id); void on_get_dialogs(FolderId folder_id, vector> &&dialog_folders, int32 total_count, vector> &&messages, @@ -348,35 +348,35 @@ class MessagesManager final : public Actor { void on_update_channel_too_long(tl_object_ptr &&update, bool force_apply); - void on_update_message_view_count(FullMessageId full_message_id, int32 view_count); + void on_update_message_view_count(MessageFullId message_full_id, int32 view_count); - void on_update_message_forward_count(FullMessageId full_message_id, int32 forward_count); + void on_update_message_forward_count(MessageFullId message_full_id, int32 forward_count); - void on_update_message_reactions(FullMessageId full_message_id, + void on_update_message_reactions(MessageFullId message_full_id, tl_object_ptr &&reactions, Promise &&promise); - void update_message_reactions(FullMessageId full_message_id, unique_ptr &&reactions); + void update_message_reactions(MessageFullId message_full_id, unique_ptr &&reactions); void try_reload_message_reactions(DialogId dialog_id, bool is_finished); - void on_get_message_reaction_list(FullMessageId full_message_id, const ReactionType &reaction_type, + void on_get_message_reaction_list(MessageFullId message_full_id, const ReactionType &reaction_type, FlatHashMap, ReactionTypeHash> reaction_types, int32 total_count); - void on_update_message_interaction_info(FullMessageId full_message_id, int32 view_count, int32 forward_count, + void on_update_message_interaction_info(MessageFullId message_full_id, int32 view_count, int32 forward_count, bool has_reply_info, tl_object_ptr &&reply_info); - void on_update_live_location_viewed(FullMessageId full_message_id); + void on_update_live_location_viewed(MessageFullId message_full_id); void on_update_some_live_location_viewed(Promise &&promise); - void on_update_message_extended_media(FullMessageId full_message_id, + void on_update_message_extended_media(MessageFullId message_full_id, telegram_api::object_ptr extended_media); - void on_external_update_message_content(FullMessageId full_message_id); + void on_external_update_message_content(MessageFullId message_full_id); - void on_update_message_content(FullMessageId full_message_id); + void on_update_message_content(MessageFullId message_full_id); void on_read_channel_inbox(ChannelId channel_id, MessageId max_message_id, int32 server_unread_count, int32 pts, const char *source); @@ -489,7 +489,7 @@ class MessagesManager final : public Actor { void set_dialog_message_ttl(DialogId dialog_id, int32 ttl, Promise &&promise); - void share_dialog_with_bot(FullMessageId full_message_id, int32 button_id, DialogId shared_dialog_id, + void share_dialog_with_bot(MessageFullId message_full_id, int32 button_id, DialogId shared_dialog_id, bool expect_user, bool only_check, Promise &&promise); Result add_local_message(DialogId dialog_id, td_api::object_ptr &&sender, @@ -508,20 +508,20 @@ class MessagesManager final : public Actor { void start_import_messages(DialogId dialog_id, int64 import_id, vector &&attached_file_ids, Promise &&promise); - void edit_message_text(FullMessageId full_message_id, tl_object_ptr &&reply_markup, + void edit_message_text(MessageFullId message_full_id, tl_object_ptr &&reply_markup, tl_object_ptr &&input_message_content, Promise &&promise); - void edit_message_live_location(FullMessageId full_message_id, tl_object_ptr &&reply_markup, + void edit_message_live_location(MessageFullId message_full_id, tl_object_ptr &&reply_markup, tl_object_ptr &&input_location, int32 heading, int32 proximity_alert_radius, Promise &&promise); - void edit_message_media(FullMessageId full_message_id, tl_object_ptr &&reply_markup, + void edit_message_media(MessageFullId message_full_id, tl_object_ptr &&reply_markup, tl_object_ptr &&input_message_content, Promise &&promise); - void edit_message_caption(FullMessageId full_message_id, tl_object_ptr &&reply_markup, + void edit_message_caption(MessageFullId message_full_id, tl_object_ptr &&reply_markup, tl_object_ptr &&input_caption, Promise &&promise); - void edit_message_reply_markup(FullMessageId full_message_id, tl_object_ptr &&reply_markup, + void edit_message_reply_markup(MessageFullId message_full_id, tl_object_ptr &&reply_markup, Promise &&promise); void edit_inline_message_text(const string &inline_message_id, tl_object_ptr &&reply_markup, @@ -543,7 +543,7 @@ class MessagesManager final : public Actor { void edit_inline_message_reply_markup(const string &inline_message_id, tl_object_ptr &&reply_markup, Promise &&promise); - void edit_message_scheduling_state(FullMessageId full_message_id, + void edit_message_scheduling_state(MessageFullId message_full_id, td_api::object_ptr &&scheduling_state, Promise &&promise); @@ -644,15 +644,15 @@ class MessagesManager final : public Actor { vector> &&blocked_peers, Promise> &&promise); - bool can_get_message_statistics(FullMessageId full_message_id); + bool can_get_message_statistics(MessageFullId message_full_id); - DialogId get_dialog_message_sender(FullMessageId full_message_id); + DialogId get_dialog_message_sender(MessageFullId message_full_id); - bool have_message_force(FullMessageId full_message_id, const char *source); + bool have_message_force(MessageFullId message_full_id, const char *source); - void get_message(FullMessageId full_message_id, Promise &&promise); + void get_message(MessageFullId message_full_id, Promise &&promise); - FullMessageId get_replied_message(DialogId dialog_id, MessageId message_id, bool force, Promise &&promise); + MessageFullId get_replied_message(DialogId dialog_id, MessageId message_id, bool force, Promise &&promise); MessageId get_dialog_pinned_message(DialogId dialog_id, Promise &&promise); @@ -661,10 +661,10 @@ class MessagesManager final : public Actor { bool get_messages(DialogId dialog_id, const vector &message_ids, Promise &&promise); - void get_message_from_server(FullMessageId full_message_id, Promise &&promise, const char *source, + void get_message_from_server(MessageFullId message_full_id, Promise &&promise, const char *source, tl_object_ptr input_message = nullptr); - void get_messages_from_server(vector &&message_ids, Promise &&promise, const char *source, + void get_messages_from_server(vector &&message_ids, Promise &&promise, const char *source, tl_object_ptr input_message = nullptr); void get_message_thread(DialogId dialog_id, MessageId message_id, Promise &&promise); @@ -675,26 +675,26 @@ class MessagesManager final : public Actor { DialogId dialog_id, MessageId message_id, DialogId expected_dialog_id, MessageId expected_message_id, Promise promise); - void get_message_viewers(FullMessageId full_message_id, + void get_message_viewers(MessageFullId message_full_id, Promise> &&promise); - void translate_message_text(FullMessageId full_message_id, const string &to_language_code, + void translate_message_text(MessageFullId message_full_id, const string &to_language_code, Promise> &&promise); - void recognize_speech(FullMessageId full_message_id, Promise &&promise); + void recognize_speech(MessageFullId message_full_id, Promise &&promise); - void rate_speech_recognition(FullMessageId full_message_id, bool is_good, Promise &&promise); + void rate_speech_recognition(MessageFullId message_full_id, bool is_good, Promise &&promise); - bool is_message_edited_recently(FullMessageId full_message_id, int32 seconds); + bool is_message_edited_recently(MessageFullId message_full_id, int32 seconds); bool is_deleted_secret_chat(DialogId dialog_id) const; - Result> get_message_link(FullMessageId full_message_id, int32 media_timestamp, bool for_group, + Result> get_message_link(MessageFullId message_full_id, int32 media_timestamp, bool for_group, bool in_message_thread); - string get_message_embedding_code(FullMessageId full_message_id, bool for_group, Promise &&promise); + string get_message_embedding_code(MessageFullId message_full_id, bool for_group, Promise &&promise); - void on_get_public_message_link(FullMessageId full_message_id, bool for_group, string url, string html); + void on_get_public_message_link(MessageFullId message_full_id, bool for_group, string url, string html); void get_message_link_info(Slice url, Promise &&promise); @@ -754,9 +754,9 @@ class MessagesManager final : public Actor { void finish_get_message_extended_media(DialogId dialog_id, const vector &message_ids); - Status open_message_content(FullMessageId full_message_id) TD_WARN_UNUSED_RESULT; + Status open_message_content(MessageFullId message_full_id) TD_WARN_UNUSED_RESULT; - void click_animated_emoji_message(FullMessageId full_message_id, + void click_animated_emoji_message(MessageFullId message_full_id, Promise> &&promise); StoryNotificationSettings get_story_notification_settings(DialogId dialog_id); @@ -813,7 +813,7 @@ class MessagesManager final : public Actor { int64 &random_id, bool use_db, Promise &&promise); struct FoundMessages { - vector full_message_ids; + vector message_full_ids; string next_offset; int32 total_count = 0; }; @@ -837,7 +837,7 @@ class MessagesManager final : public Actor { void search_dialog_recent_location_messages(DialogId dialog_id, int32 limit, Promise> &&promise); - vector get_active_live_location_messages(Promise &&promise); + vector get_active_live_location_messages(Promise &&promise); int64 get_dialog_message_by_date(DialogId dialog_id, int32 date, Promise &&promise); @@ -859,21 +859,21 @@ class MessagesManager final : public Actor { void get_dialog_message_count(DialogId dialog_id, MessageSearchFilter filter, bool return_local, Promise &&promise); - void get_dialog_message_position(FullMessageId full_message_id, MessageSearchFilter filter, + void get_dialog_message_position(MessageFullId message_full_id, MessageSearchFilter filter, MessageId top_thread_message_id, Promise &&promise); vector get_dialog_scheduled_messages(DialogId dialog_id, bool force, bool ignore_result, Promise &&promise); - Result> get_message_available_reactions(FullMessageId full_message_id, + Result> get_message_available_reactions(MessageFullId message_full_id, int32 row_size); - void add_message_reaction(FullMessageId full_message_id, ReactionType reaction_type, bool is_big, bool add_to_recent, + void add_message_reaction(MessageFullId message_full_id, ReactionType reaction_type, bool is_big, bool add_to_recent, Promise &&promise); - void remove_message_reaction(FullMessageId full_message_id, ReactionType reaction_type, Promise &&promise); + void remove_message_reaction(MessageFullId message_full_id, ReactionType reaction_type, Promise &&promise); - void get_message_public_forwards(FullMessageId full_message_id, string offset, int32 limit, + void get_message_public_forwards(MessageFullId message_full_id, string offset, int32 limit, Promise> &&promise); tl_object_ptr get_dialog_message_by_date_object(int64 random_id); @@ -881,13 +881,13 @@ class MessagesManager final : public Actor { td_api::object_ptr get_dialog_event_log_message_object( DialogId dialog_id, tl_object_ptr &&message, DialogId &sender_dialog_id); - tl_object_ptr get_message_object(FullMessageId full_message_id, const char *source); + tl_object_ptr get_message_object(MessageFullId message_full_id, const char *source); tl_object_ptr get_messages_object(int32 total_count, DialogId dialog_id, const vector &message_ids, bool skip_not_found, const char *source); - tl_object_ptr get_messages_object(int32 total_count, const vector &full_message_ids, + tl_object_ptr get_messages_object(int32 total_count, const vector &message_full_ids, bool skip_not_found, const char *source); void process_pts_update(tl_object_ptr &&update_ptr); @@ -957,7 +957,7 @@ class MessagesManager final : public Actor { void check_send_message_result(int64 random_id, DialogId dialog_id, const telegram_api::Updates *updates_ptr, const char *source); - FullMessageId on_send_message_success(int64 random_id, MessageId new_message_id, int32 date, int32 ttl_period, + MessageFullId on_send_message_success(int64 random_id, MessageId new_message_id, int32 date, int32 ttl_period, FileId new_file_id, const char *source); void on_send_message_file_parts_missing(int64 random_id, vector &&bad_parts); @@ -997,7 +997,7 @@ class MessagesManager final : public Actor { vector> users, vector> chats); - FileSourceId get_message_file_source_id(FullMessageId full_message_id, bool force = false); + FileSourceId get_message_file_source_id(MessageFullId message_full_id, bool force = false); struct MessagePushNotificationInfo { NotificationGroupId group_id; @@ -1035,28 +1035,28 @@ class MessagesManager final : public Actor { void on_binlog_events(vector &&events); - void set_poll_answer(FullMessageId full_message_id, vector &&option_ids, Promise &&promise); + void set_poll_answer(MessageFullId message_full_id, vector &&option_ids, Promise &&promise); - void get_poll_voters(FullMessageId full_message_id, int32 option_id, int32 offset, int32 limit, + void get_poll_voters(MessageFullId message_full_id, int32 option_id, int32 offset, int32 limit, Promise> &&promise); - void stop_poll(FullMessageId full_message_id, td_api::object_ptr &&reply_markup, + void stop_poll(MessageFullId message_full_id, td_api::object_ptr &&reply_markup, Promise &&promise); - Result get_login_button_url(FullMessageId full_message_id, int64 button_id); + Result get_login_button_url(MessageFullId message_full_id, int64 button_id); - Result get_invoice_message_id(FullMessageId full_message_id); + Result get_invoice_message_id(MessageFullId message_full_id); - Result get_payment_successful_message_id(FullMessageId full_message_id); + Result get_payment_successful_message_id(MessageFullId message_full_id); - bool can_set_game_score(FullMessageId full_message_id) const; + bool can_set_game_score(MessageFullId message_full_id) const; void get_current_state(vector> &updates) const; - void add_message_file_to_downloads(FullMessageId full_message_id, FileId file_id, int32 priority, + void add_message_file_to_downloads(MessageFullId message_full_id, FileId file_id, int32 priority, Promise> promise); - void get_message_file_search_text(FullMessageId full_message_id, string unique_file_id, Promise promise); + void get_message_file_search_text(MessageFullId message_full_id, string unique_file_id, Promise promise); private: class PendingPtsUpdate { @@ -1150,13 +1150,13 @@ class MessagesManager final : public Actor { if (forward_info.sender_dialog_id.is_valid()) { string_builder << ", source "; if (forward_info.message_id.is_valid()) { - string_builder << FullMessageId(forward_info.sender_dialog_id, forward_info.message_id); + string_builder << MessageFullId(forward_info.sender_dialog_id, forward_info.message_id); } else { string_builder << forward_info.sender_dialog_id; } } if (forward_info.from_dialog_id.is_valid() || forward_info.from_message_id.is_valid()) { - string_builder << ", from " << FullMessageId(forward_info.from_dialog_id, forward_info.from_message_id); + string_builder << ", from " << MessageFullId(forward_info.from_dialog_id, forward_info.from_message_id); } return string_builder << " at " << forward_info.date << ']'; } @@ -1805,7 +1805,7 @@ class MessagesManager final : public Actor { void get_dialog_message_count_from_server(DialogId dialog_id, MessageSearchFilter filter, Promise &&promise); - FullMessageId on_get_message(MessageInfo &&message_info, const bool from_update, const bool is_channel_message, + MessageFullId on_get_message(MessageInfo &&message_info, const bool from_update, const bool is_channel_message, const char *source); Result process_input_message_content( @@ -1860,7 +1860,7 @@ class MessagesManager final : public Actor { 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(MessageFullId message_full_id) TD_WARN_UNUSED_RESULT; Status can_get_message_viewers(DialogId dialog_id, const Message *m) const TD_WARN_UNUSED_RESULT; @@ -1872,7 +1872,7 @@ class MessagesManager final : public Actor { MessageId get_persistent_message_id(const Dialog *d, MessageId message_id) const; - static FullMessageId get_replied_message_id(DialogId dialog_id, const Message *m); + static MessageFullId get_replied_message_id(DialogId dialog_id, const Message *m); MessageInputReplyTo get_message_input_reply_to(Dialog *d, MessageId top_thread_message_id, td_api::object_ptr &&reply_to, bool for_draft); @@ -1887,7 +1887,7 @@ class MessagesManager final : public Actor { bool process_channel_update(tl_object_ptr &&update_ptr); - void on_message_edited(FullMessageId full_message_id, int32 pts, bool had_message); + void on_message_edited(MessageFullId message_full_id, int32 pts, bool had_message); void delete_messages_from_updates(const vector &message_ids, bool is_permanent); @@ -2118,7 +2118,7 @@ class MessagesManager final : public Actor { void on_pending_message_views_timeout(DialogId dialog_id); - void update_message_interaction_info(FullMessageId full_message_id, int32 view_count, int32 forward_count, + void update_message_interaction_info(MessageFullId message_full_id, int32 view_count, int32 forward_count, bool has_reply_info, tl_object_ptr &&reply_info, bool has_reactions, unique_ptr &&reactions); @@ -2137,7 +2137,7 @@ class MessagesManager final : public Actor { void on_message_reply_info_changed(DialogId dialog_id, const Message *m) const; - Result get_top_thread_full_message_id(DialogId dialog_id, const Message *m, bool allow_non_root) const; + Result get_top_thread_message_full_id(DialogId dialog_id, const Message *m, bool allow_non_root) const; td_api::object_ptr get_message_interaction_info_object(DialogId dialog_id, const Message *m) const; @@ -2255,11 +2255,11 @@ class MessagesManager final : public Actor { bool is_message_auto_read(DialogId dialog_id, bool is_outgoing) const; - void fail_send_message(FullMessageId full_message_id, int32 error_code, const string &error_message); + void fail_send_message(MessageFullId message_full_id, int32 error_code, const string &error_message); - void fail_send_message(FullMessageId full_message_id, Status error); + void fail_send_message(MessageFullId message_full_id, Status error); - void fail_edit_message_media(FullMessageId full_message_id, Status &&error); + void fail_edit_message_media(MessageFullId message_full_id, Status &&error); void on_dialog_updated(DialogId dialog_id, const char *source); @@ -2318,7 +2318,7 @@ class MessagesManager final : public Actor { void on_message_notification_changed(Dialog *d, const Message *m, const char *source); - bool need_delete_file(FullMessageId full_message_id, FileId file_id) const; + bool need_delete_file(MessageFullId message_full_id, FileId file_id) const; bool need_delete_message_files(DialogId dialog_id, const Message *m) const; @@ -2457,7 +2457,7 @@ class MessagesManager final : public Actor { void send_update_message_unread_reactions(DialogId dialog_id, const Message *m, int32 unread_reaction_count) const; - void send_update_message_live_location_viewed(FullMessageId full_message_id); + void send_update_message_live_location_viewed(MessageFullId message_full_id); void send_update_delete_messages(DialogId dialog_id, vector &&message_ids, bool is_permanent) const; @@ -2674,7 +2674,7 @@ class MessagesManager final : public Actor { void set_message_reactions(Dialog *d, Message *m, bool is_big, bool add_to_recent, Promise &&promise); - void on_set_message_reactions(FullMessageId full_message_id, Result result, Promise promise); + void on_set_message_reactions(MessageFullId message_full_id, Result result, Promise promise); void on_read_message_reactions(DialogId dialog_id, vector &&message_ids, Result &&result); @@ -2694,7 +2694,7 @@ class MessagesManager final : public Actor { static bool need_poll_message_reactions(const Dialog *d, const Message *m); - void queue_message_reactions_reload(FullMessageId full_message_id); + void queue_message_reactions_reload(MessageFullId message_full_id); void queue_message_reactions_reload(DialogId dialog_id, const vector &message_ids); @@ -2803,14 +2803,14 @@ class MessagesManager final : public Actor { static const Message *get_message(const Dialog *d, MessageId message_id); static const Message *get_message_static(const Dialog *d, MessageId message_id); - Message *get_message(FullMessageId full_message_id); - const Message *get_message(FullMessageId full_message_id) const; + Message *get_message(MessageFullId message_full_id); + const Message *get_message(MessageFullId message_full_id) const; bool have_message_force(Dialog *d, MessageId message_id, const char *source); Message *get_message_force(Dialog *d, MessageId message_id, const char *source); - Message *get_message_force(FullMessageId full_message_id, const char *source); + Message *get_message_force(MessageFullId message_full_id, const char *source); void get_message_force_from_server(Dialog *d, MessageId message_id, Promise &&promise, tl_object_ptr input_message = nullptr); @@ -2867,7 +2867,7 @@ class MessagesManager final : public Actor { static bool is_forward_info_sender_hidden(const MessageForwardInfo *forward_info); unique_ptr get_message_forward_info( - tl_object_ptr &&forward_header, FullMessageId full_message_id); + tl_object_ptr &&forward_header, MessageFullId message_full_id); td_api::object_ptr get_message_forward_info_object( const unique_ptr &forward_info) const; @@ -2905,7 +2905,7 @@ class MessagesManager final : public Actor { void ttl_db_on_result(Result> r_result, bool dummy); - void on_restore_missing_message_after_get_difference(FullMessageId full_message_id, MessageId old_message_id, + void on_restore_missing_message_after_get_difference(MessageFullId message_full_id, MessageId old_message_id, Result result); void on_get_message_link_dialog(MessageLinkInfo &&info, DialogId dialog_id, Promise &&promise); @@ -2942,13 +2942,13 @@ class MessagesManager final : public Actor { void on_message_db_calls_result(Result result, int64 random_id, MessageId first_db_message_id, MessageSearchFilter filter, Promise &&promise); - void on_load_active_live_location_full_message_ids_from_database(string value); + void on_load_active_live_location_message_full_ids_from_database(string value); void on_load_active_live_location_messages_finished(); void try_add_active_live_location(DialogId dialog_id, const Message *m); - void add_active_live_location(FullMessageId full_message_id); + void add_active_live_location(MessageFullId message_full_id); bool delete_active_live_location(DialogId dialog_id, const Message *m); @@ -2958,7 +2958,7 @@ class MessagesManager final : public Actor { void view_message_live_location_on_server(int64 task_id); - void view_message_live_location_on_server_impl(int64 task_id, FullMessageId full_message_id); + void view_message_live_location_on_server_impl(int64 task_id, MessageFullId message_full_id); void on_message_live_location_viewed_on_server(int64 task_id); @@ -3149,7 +3149,7 @@ class MessagesManager final : public Actor { Status can_import_messages(DialogId dialog_id); - void send_get_message_public_forwards_query(DcId dc_id, FullMessageId full_message_id, string offset, int32 limit, + void send_get_message_public_forwards_query(DcId dc_id, MessageFullId message_full_id, string offset, int32 limit, Promise> &&promise); void add_sponsored_dialog(const Dialog *d, DialogSource source); @@ -3297,16 +3297,16 @@ class MessagesManager final : public Actor { double last_channel_pts_jump_warning_time_ = 0; - FlatHashMap, FileIdHash> + FlatHashMap, FileIdHash> being_uploaded_files_; // file_id -> message, thumbnail_file_id struct UploadedThumbnailInfo { - FullMessageId full_message_id; + MessageFullId message_full_id; FileId file_id; // original file file_id tl_object_ptr input_file; // original file InputFile }; FlatHashMap being_uploaded_thumbnails_; // thumbnail_file_id -> ... struct UploadedSecretThumbnailInfo { - FullMessageId full_message_id; + MessageFullId message_full_id; FileId file_id; // original file file_id tl_object_ptr input_file; // original file InputEncryptedFile }; @@ -3317,10 +3317,10 @@ class MessagesManager final : public Actor { class TtlNode final : private HeapNode { public: TtlNode(DialogId dialog_id, MessageId message_id, bool by_ttl_period) - : full_message_id_(dialog_id, message_id), by_ttl_period_(by_ttl_period) { + : message_full_id_(dialog_id, message_id), by_ttl_period_(by_ttl_period) { } - FullMessageId full_message_id_; + MessageFullId message_full_id_; bool by_ttl_period_; HeapNode *as_heap_node() const { @@ -3331,12 +3331,12 @@ class MessagesManager final : public Actor { } bool operator==(const TtlNode &other) const { - return full_message_id_ == other.full_message_id_; + return message_full_id_ == other.message_full_id_; } }; struct TtlNodeHash { uint32 operator()(const TtlNode &ttl_node) const { - return FullMessageIdHash()(ttl_node.full_message_id_) * 2 + static_cast(ttl_node.by_ttl_period_); + return MessageFullIdHash()(ttl_node.message_full_id_) * 2 + static_cast(ttl_node.by_ttl_period_); } }; std::unordered_set ttl_nodes_; @@ -3349,9 +3349,9 @@ class MessagesManager final : public Actor { bool ttl_db_has_query_ = false; Slot ttl_db_slot_; - FlatHashMap being_sent_messages_; // message_random_id -> message + FlatHashMap being_sent_messages_; // message_random_id -> message - FlatHashMap update_message_ids_; // new_message_id -> temporary_id + FlatHashMap update_message_ids_; // new_message_id -> temporary_id FlatHashMap, DialogIdHash> update_scheduled_message_ids_; // new_message_id -> temporary_id @@ -3454,7 +3454,7 @@ class MessagesManager final : public Actor { }; FlatHashMap found_common_dialogs_; - FlatHashMap get_dialog_message_by_date_results_; + FlatHashMap get_dialog_message_by_date_results_; FlatHashMap> found_dialog_message_calendars_; FlatHashMap found_dialog_messages_; // random_id -> FoundDialogMessages @@ -3472,15 +3472,15 @@ class MessagesManager final : public Actor { FlatHashMap>, DialogIdHash> get_dialog_queries_; FlatHashMap get_dialog_query_log_event_id_; - FlatHashMap replied_by_yet_unsent_messages_; - FlatHashMap, FullMessageIdHash> replied_yet_unsent_messages_; + FlatHashMap replied_by_yet_unsent_messages_; + FlatHashMap, MessageFullIdHash> replied_yet_unsent_messages_; - // full_message_id -> replies with media timestamps - FlatHashMap, FullMessageIdHash> + // message_full_id -> replies with media timestamps + FlatHashMap, MessageFullIdHash> message_to_replied_media_timestamp_messages_; // story_full_id -> replies with media timestamps - FlatHashMap, StoryFullIdHash> + FlatHashMap, StoryFullIdHash> story_to_replied_media_timestamp_messages_; struct ActiveDialogAction { @@ -3560,7 +3560,7 @@ class MessagesManager final : public Actor { Hints dialogs_hints_; // search dialogs by title and usernames - FlatHashSet active_live_location_full_message_ids_; + FlatHashSet active_live_location_message_full_ids_; bool are_active_live_location_messages_loaded_ = false; vector> load_active_live_location_messages_queries_; @@ -3637,7 +3637,7 @@ class MessagesManager final : public Actor { CallsDbState calls_db_state_; int64 viewed_live_location_task_id_ = 0; - FlatHashMap viewed_live_location_tasks_; // task_id -> task + FlatHashMap viewed_live_location_tasks_; // task_id -> task FlatHashMap, DialogIdHash> pending_viewed_live_locations_; // ... -> task_id @@ -3649,7 +3649,7 @@ class MessagesManager final : public Actor { FlatHashMap set_typing_query_; - WaitFreeHashMap full_message_id_to_file_source_id_; + WaitFreeHashMap message_full_id_to_file_source_id_; FlatHashMap last_outgoing_forwarded_message_date_; @@ -3679,8 +3679,8 @@ class MessagesManager final : public Actor { FlatHashMap previous_repaired_read_inbox_max_message_id_; - FlatHashMap yet_unsent_full_message_id_to_persistent_message_id_; - FlatHashMap, FullMessageIdHash> + FlatHashMap yet_unsent_message_full_id_to_persistent_message_id_; + FlatHashMap, MessageFullIdHash> yet_unsent_thread_message_ids_; // {dialog_id, top_thread_message_id} -> yet unsent message IDs FlatHashMap, DialogIdHash> dialog_suffix_load_queries_; @@ -3700,9 +3700,9 @@ class MessagesManager final : public Actor { int32 query_count = 0; bool was_updated = false; }; - FlatHashMap pending_reactions_; + FlatHashMap pending_reactions_; - FlatHashMap pending_read_reactions_; + FlatHashMap pending_read_reactions_; vector active_reaction_types_; FlatHashMap active_reaction_pos_; @@ -3717,7 +3717,7 @@ class MessagesManager final : public Actor { DialogId sponsored_dialog_id_; DialogSource sponsored_dialog_source_; - FullMessageId being_readded_message_id_; + MessageFullId being_readded_message_id_; DialogId being_added_dialog_id_; DialogId being_added_by_new_message_dialog_id_; diff --git a/td/telegram/NotificationSettingsManager.h b/td/telegram/NotificationSettingsManager.h index 137c370e8..6a8ea2229 100644 --- a/td/telegram/NotificationSettingsManager.h +++ b/td/telegram/NotificationSettingsManager.h @@ -10,7 +10,7 @@ #include "td/telegram/DialogNotificationSettings.h" #include "td/telegram/files/FileId.h" #include "td/telegram/files/FileSourceId.h" -#include "td/telegram/FullMessageId.h" +#include "td/telegram/MessageFullId.h" #include "td/telegram/MessageId.h" #include "td/telegram/NotificationSettingsScope.h" #include "td/telegram/ScopeNotificationSettings.h" @@ -225,7 +225,7 @@ class NotificationSettingsManager final : public Actor { vector> reload_saved_ringtones_queries_; vector> repair_saved_ringtones_queries_; - FlatHashMap>, FullMessageIdHash> get_dialog_notification_settings_queries_; + FlatHashMap>, MessageFullIdHash> get_dialog_notification_settings_queries_; }; } // namespace td diff --git a/td/telegram/Payments.cpp b/td/telegram/Payments.cpp index 71a082204..a51458cce 100644 --- a/td/telegram/Payments.cpp +++ b/td/telegram/Payments.cpp @@ -863,12 +863,12 @@ void send_payment_form(Td *td, td_api::object_ptr &&input_ std::move(input_credentials), tip_amount); } -void get_payment_receipt(Td *td, FullMessageId full_message_id, +void get_payment_receipt(Td *td, MessageFullId message_full_id, Promise> &&promise) { TRY_RESULT_PROMISE(promise, server_message_id, - td->messages_manager_->get_payment_successful_message_id(full_message_id)); + td->messages_manager_->get_payment_successful_message_id(message_full_id)); td->create_handler(std::move(promise)) - ->send(full_message_id.get_dialog_id(), server_message_id); + ->send(message_full_id.get_dialog_id(), server_message_id); } void get_saved_order_info(Td *td, Promise> &&promise) { diff --git a/td/telegram/Payments.h b/td/telegram/Payments.h index 4ca87b961..506aaf0ac 100644 --- a/td/telegram/Payments.h +++ b/td/telegram/Payments.h @@ -6,7 +6,7 @@ // #pragma once -#include "td/telegram/FullMessageId.h" +#include "td/telegram/MessageFullId.h" #include "td/telegram/td_api.h" #include "td/utils/common.h" @@ -37,7 +37,7 @@ void send_payment_form(Td *td, td_api::object_ptr &&input_ const td_api::object_ptr &credentials, int64 tip_amount, Promise> &&promise); -void get_payment_receipt(Td *td, FullMessageId full_message_id, +void get_payment_receipt(Td *td, MessageFullId message_full_id, Promise> &&promise); void get_saved_order_info(Td *td, Promise> &&promise); diff --git a/td/telegram/PollManager.cpp b/td/telegram/PollManager.cpp index cf3fc3836..4eeebcc5b 100644 --- a/td/telegram/PollManager.cpp +++ b/td/telegram/PollManager.cpp @@ -57,10 +57,10 @@ class GetPollResultsQuery final : public Td::ResultHandler { explicit GetPollResultsQuery(Promise> &&promise) : promise_(std::move(promise)) { } - void send(PollId poll_id, FullMessageId full_message_id) { + void send(PollId poll_id, MessageFullId message_full_id) { poll_id_ = poll_id; - dialog_id_ = full_message_id.get_dialog_id(); - message_id_ = full_message_id.get_message_id(); + dialog_id_ = message_full_id.get_dialog_id(); + message_id_ = message_full_id.get_message_id(); auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read); if (input_peer == nullptr) { LOG(INFO) << "Can't reget poll, because have no read access to " << dialog_id_; @@ -105,9 +105,9 @@ class GetPollVotersQuery final : public Td::ResultHandler { : promise_(std::move(promise)) { } - void send(PollId poll_id, FullMessageId full_message_id, BufferSlice &&option, const string &offset, int32 limit) { + void send(PollId poll_id, MessageFullId message_full_id, BufferSlice &&option, const string &offset, int32 limit) { poll_id_ = poll_id; - dialog_id_ = full_message_id.get_dialog_id(); + dialog_id_ = message_full_id.get_dialog_id(); auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read); if (input_peer == nullptr) { LOG(INFO) << "Can't get poll, because have no read access to " << dialog_id_; @@ -120,7 +120,7 @@ class GetPollVotersQuery final : public Td::ResultHandler { flags |= telegram_api::messages_getPollVotes::OFFSET_MASK; } - auto message_id = full_message_id.get_message_id().get_server_message_id().get(); + auto message_id = message_full_id.get_message_id().get_server_message_id().get(); send_query(G()->net_query_creator().create(telegram_api::messages_getPollVotes( flags, std::move(input_peer), message_id, std::move(option), offset, limit))); } @@ -151,16 +151,16 @@ class SendVoteQuery final : public Td::ResultHandler { explicit SendVoteQuery(Promise> &&promise) : promise_(std::move(promise)) { } - void send(FullMessageId full_message_id, vector &&options, PollId poll_id, uint64 generation, + void send(MessageFullId message_full_id, vector &&options, PollId poll_id, uint64 generation, NetQueryRef *query_ref) { - dialog_id_ = full_message_id.get_dialog_id(); + dialog_id_ = message_full_id.get_dialog_id(); auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read); if (input_peer == nullptr) { LOG(INFO) << "Can't set poll answer, because have no read access to " << dialog_id_; return on_error(Status::Error(400, "Can't access the chat")); } - auto message_id = full_message_id.get_message_id().get_server_message_id().get(); + auto message_id = message_full_id.get_message_id().get_server_message_id().get(); auto query = G()->net_query_creator().create( telegram_api::messages_sendVote(std::move(input_peer), message_id, std::move(options)), {{poll_id}, {dialog_id_}}); @@ -193,8 +193,8 @@ class StopPollQuery final : public Td::ResultHandler { explicit StopPollQuery(Promise &&promise) : promise_(std::move(promise)) { } - void send(FullMessageId full_message_id, unique_ptr &&reply_markup, PollId poll_id) { - dialog_id_ = full_message_id.get_dialog_id(); + void send(MessageFullId message_full_id, unique_ptr &&reply_markup, PollId poll_id) { + dialog_id_ = message_full_id.get_dialog_id(); auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Edit); if (input_peer == nullptr) { LOG(INFO) << "Can't close poll, because have no edit access to " << dialog_id_; @@ -207,7 +207,7 @@ class StopPollQuery final : public Td::ResultHandler { flags |= telegram_api::messages_editMessage::REPLY_MARKUP_MASK; } - auto message_id = full_message_id.get_message_id().get_server_message_id().get(); + auto message_id = message_full_id.get_message_id().get_server_message_id().get(); auto poll = telegram_api::make_object(); poll->flags_ |= telegram_api::poll::CLOSED_MASK; auto input_media = telegram_api::make_object(0, std::move(poll), @@ -338,14 +338,14 @@ void PollManager::notify_on_poll_update(PollId poll_id) { } if (server_poll_messages_.count(poll_id) > 0) { - server_poll_messages_[poll_id].foreach([&](const FullMessageId &full_message_id) { - td_->messages_manager_->on_external_update_message_content(full_message_id); + server_poll_messages_[poll_id].foreach([&](const MessageFullId &message_full_id) { + td_->messages_manager_->on_external_update_message_content(message_full_id); }); } if (other_poll_messages_.count(poll_id) > 0) { - other_poll_messages_[poll_id].foreach([&](const FullMessageId &full_message_id) { - td_->messages_manager_->on_external_update_message_content(full_message_id); + other_poll_messages_[poll_id].foreach([&](const MessageFullId &message_full_id) { + td_->messages_manager_->on_external_update_message_content(message_full_id); }); } } @@ -668,17 +668,17 @@ PollId PollManager::create_poll(string &&question, vector &&options, boo return poll_id; } -void PollManager::register_poll(PollId poll_id, FullMessageId full_message_id, const char *source) { +void PollManager::register_poll(PollId poll_id, MessageFullId message_full_id, const char *source) { CHECK(have_poll(poll_id)); - if (full_message_id.get_message_id().is_scheduled() || !full_message_id.get_message_id().is_server()) { - other_poll_messages_[poll_id].insert(full_message_id); + if (message_full_id.get_message_id().is_scheduled() || !message_full_id.get_message_id().is_server()) { + other_poll_messages_[poll_id].insert(message_full_id); if (!G()->close_flag()) { unload_poll_timeout_.cancel_timeout(poll_id.get()); } return; } - LOG(INFO) << "Register " << poll_id << " from " << full_message_id << " from " << source; - server_poll_messages_[poll_id].insert(full_message_id); + LOG(INFO) << "Register " << poll_id << " from " << message_full_id << " from " << source; + server_poll_messages_[poll_id].insert(message_full_id); auto poll = get_poll(poll_id); CHECK(poll != nullptr); if (!td_->auth_manager_->is_bot() && !is_local_poll_id(poll_id) && @@ -690,12 +690,12 @@ void PollManager::register_poll(PollId poll_id, FullMessageId full_message_id, c } } -void PollManager::unregister_poll(PollId poll_id, FullMessageId full_message_id, const char *source) { +void PollManager::unregister_poll(PollId poll_id, MessageFullId message_full_id, const char *source) { CHECK(have_poll(poll_id)); - if (full_message_id.get_message_id().is_scheduled() || !full_message_id.get_message_id().is_server()) { + if (message_full_id.get_message_id().is_scheduled() || !message_full_id.get_message_id().is_server()) { auto &message_ids = other_poll_messages_[poll_id]; - auto is_deleted = message_ids.erase(full_message_id) > 0; - LOG_CHECK(is_deleted) << source << ' ' << poll_id << ' ' << full_message_id; + auto is_deleted = message_ids.erase(message_full_id) > 0; + LOG_CHECK(is_deleted) << source << ' ' << poll_id << ' ' << message_full_id; if (is_local_poll_id(poll_id)) { CHECK(message_ids.empty()); forget_local_poll(poll_id); @@ -707,10 +707,10 @@ void PollManager::unregister_poll(PollId poll_id, FullMessageId full_message_id, } return; } - LOG(INFO) << "Unregister " << poll_id << " from " << full_message_id << " from " << source; + LOG(INFO) << "Unregister " << poll_id << " from " << message_full_id << " from " << source; auto &message_ids = server_poll_messages_[poll_id]; - auto is_deleted = message_ids.erase(full_message_id) > 0; - LOG_CHECK(is_deleted) << source << ' ' << poll_id << ' ' << full_message_id; + auto is_deleted = message_ids.erase(message_full_id) > 0; + LOG_CHECK(is_deleted) << source << ' ' << poll_id << ' ' << message_full_id; if (is_local_poll_id(poll_id)) { CHECK(message_ids.empty()); forget_local_poll(poll_id); @@ -777,7 +777,7 @@ string PollManager::get_poll_search_text(PollId poll_id) const { return result; } -void PollManager::set_poll_answer(PollId poll_id, FullMessageId full_message_id, vector &&option_ids, +void PollManager::set_poll_answer(PollId poll_id, MessageFullId message_full_id, vector &&option_ids, Promise &&promise) { td::unique(option_ids); @@ -825,35 +825,35 @@ void PollManager::set_poll_answer(PollId poll_id, FullMessageId full_message_id, } } - do_set_poll_answer(poll_id, full_message_id, std::move(options), 0, std::move(promise)); + do_set_poll_answer(poll_id, message_full_id, std::move(options), 0, std::move(promise)); } class PollManager::SetPollAnswerLogEvent { public: PollId poll_id_; - FullMessageId full_message_id_; + MessageFullId message_full_id_; vector options_; template void store(StorerT &storer) const { td::store(poll_id_, storer); - td::store(full_message_id_, storer); + td::store(message_full_id_, storer); td::store(options_, storer); } template void parse(ParserT &parser) { td::parse(poll_id_, parser); - td::parse(full_message_id_, parser); + td::parse(message_full_id_, parser); td::parse(options_, parser); } }; -void PollManager::do_set_poll_answer(PollId poll_id, FullMessageId full_message_id, vector &&options, +void PollManager::do_set_poll_answer(PollId poll_id, MessageFullId message_full_id, vector &&options, uint64 log_event_id, Promise &&promise) { - LOG(INFO) << "Set answer in " << poll_id << " from " << full_message_id; - if (!poll_id.is_valid() || !full_message_id.get_dialog_id().is_valid() || - !full_message_id.get_message_id().is_valid()) { + LOG(INFO) << "Set answer in " << poll_id << " from " << message_full_id; + if (!poll_id.is_valid() || !message_full_id.get_dialog_id().is_valid() || + !message_full_id.get_message_id().is_valid()) { CHECK(log_event_id != 0); LOG(ERROR) << "Invalid SetPollAnswer log event"; binlog_erase(G()->td_db()->get_binlog(), log_event_id); @@ -877,7 +877,7 @@ void PollManager::do_set_poll_answer(PollId poll_id, FullMessageId full_message_ if (log_event_id == 0 && G()->use_message_database()) { SetPollAnswerLogEvent log_event; log_event.poll_id_ = poll_id; - log_event.full_message_id_ = full_message_id; + log_event.message_full_id_ = message_full_id; log_event.options_ = options; auto storer = get_log_event_storer(log_event); if (pending_answer.generation_ == 0) { @@ -925,7 +925,7 @@ void PollManager::do_set_poll_answer(PollId poll_id, FullMessageId full_message_ send_closure(actor_id, &PollManager::on_set_poll_answer, poll_id, generation, std::move(result)); }); td_->create_handler(std::move(query_promise)) - ->send(full_message_id, std::move(sent_options), poll_id, generation, &pending_answer.query_ref_); + ->send(message_full_id, std::move(sent_options), poll_id, generation, &pending_answer.query_ref_); } void PollManager::on_set_poll_answer(PollId poll_id, uint64 generation, @@ -1063,7 +1063,7 @@ td_api::object_ptr PollManager::get_poll_voters_object( return result; } -void PollManager::get_poll_voters(PollId poll_id, FullMessageId full_message_id, int32 option_id, int32 offset, +void PollManager::get_poll_voters(PollId poll_id, MessageFullId message_full_id, int32 option_id, int32 offset, int32 limit, Promise> &&promise) { if (is_local_poll_id(poll_id)) { return promise.set_error(Status::Error(400, "Poll results can't be received")); @@ -1126,7 +1126,7 @@ void PollManager::get_poll_voters(PollId poll_id, FullMessageId full_message_id, std::move(result)); }); td_->create_handler(std::move(query_promise)) - ->send(poll_id, full_message_id, BufferSlice(poll->options_[option_id].data_), voters.next_offset_, + ->send(poll_id, message_full_id, BufferSlice(poll->options_[option_id].data_), voters.next_offset_, max(limit, 10)); } @@ -1223,10 +1223,10 @@ void PollManager::on_get_poll_voters(PollId poll_id, int32 option_id, string off } } -void PollManager::stop_poll(PollId poll_id, FullMessageId full_message_id, unique_ptr &&reply_markup, +void PollManager::stop_poll(PollId poll_id, MessageFullId message_full_id, unique_ptr &&reply_markup, Promise &&promise) { if (is_local_poll_id(poll_id)) { - LOG(ERROR) << "Receive local " << poll_id << " from " << full_message_id << " in stop_poll"; + LOG(ERROR) << "Receive local " << poll_id << " from " << message_full_id << " in stop_poll"; stop_local_poll(poll_id); promise.set_value(Unit()); return; @@ -1244,34 +1244,34 @@ void PollManager::stop_poll(PollId poll_id, FullMessageId full_message_id, uniqu save_poll(poll, poll_id); notify_on_poll_update(poll_id); - do_stop_poll(poll_id, full_message_id, std::move(reply_markup), 0, std::move(promise)); + do_stop_poll(poll_id, message_full_id, std::move(reply_markup), 0, std::move(promise)); } class PollManager::StopPollLogEvent { public: PollId poll_id_; - FullMessageId full_message_id_; + MessageFullId message_full_id_; template void store(StorerT &storer) const { td::store(poll_id_, storer); - td::store(full_message_id_, storer); + td::store(message_full_id_, storer); } template void parse(ParserT &parser) { td::parse(poll_id_, parser); - td::parse(full_message_id_, parser); + td::parse(message_full_id_, parser); } }; -void PollManager::do_stop_poll(PollId poll_id, FullMessageId full_message_id, unique_ptr &&reply_markup, +void PollManager::do_stop_poll(PollId poll_id, MessageFullId message_full_id, unique_ptr &&reply_markup, uint64 log_event_id, Promise &&promise) { - LOG(INFO) << "Stop " << poll_id << " from " << full_message_id; + LOG(INFO) << "Stop " << poll_id << " from " << message_full_id; CHECK(poll_id.is_valid()); if (log_event_id == 0 && G()->use_message_database() && reply_markup == nullptr) { - StopPollLogEvent log_event{poll_id, full_message_id}; + StopPollLogEvent log_event{poll_id, message_full_id}; log_event_id = binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::StopPoll, get_log_event_storer(log_event)); } @@ -1280,16 +1280,16 @@ void PollManager::do_stop_poll(PollId poll_id, FullMessageId full_message_id, un bool is_inserted = being_closed_polls_.insert(poll_id).second; CHECK(is_inserted); - auto new_promise = PromiseCreator::lambda([actor_id = actor_id(this), poll_id, full_message_id, log_event_id, + auto new_promise = PromiseCreator::lambda([actor_id = actor_id(this), poll_id, message_full_id, log_event_id, promise = std::move(promise)](Result result) mutable { - send_closure(actor_id, &PollManager::on_stop_poll_finished, poll_id, full_message_id, log_event_id, + send_closure(actor_id, &PollManager::on_stop_poll_finished, poll_id, message_full_id, log_event_id, std::move(result), std::move(promise)); }); - td_->create_handler(std::move(new_promise))->send(full_message_id, std::move(reply_markup), poll_id); + td_->create_handler(std::move(new_promise))->send(message_full_id, std::move(reply_markup), poll_id); } -void PollManager::on_stop_poll_finished(PollId poll_id, FullMessageId full_message_id, uint64 log_event_id, +void PollManager::on_stop_poll_finished(PollId poll_id, MessageFullId message_full_id, uint64 log_event_id, Result &&result, Promise &&promise) { being_closed_polls_.erase(poll_id); @@ -1298,9 +1298,9 @@ void PollManager::on_stop_poll_finished(PollId poll_id, FullMessageId full_messa } if (td_->auth_manager_->is_bot()) { - if ((server_poll_messages_.count(poll_id) > 0 && server_poll_messages_[poll_id].count(full_message_id) > 0) || - (other_poll_messages_.count(poll_id) > 0 && other_poll_messages_[poll_id].count(full_message_id) > 0)) { - td_->messages_manager_->on_external_update_message_content(full_message_id); + if ((server_poll_messages_.count(poll_id) > 0 && server_poll_messages_[poll_id].count(message_full_id) > 0) || + (other_poll_messages_.count(poll_id) > 0 && other_poll_messages_[poll_id].count(message_full_id) > 0)) { + td_->messages_manager_->on_external_update_message_content(message_full_id); } } @@ -1344,13 +1344,13 @@ void PollManager::on_update_poll_timeout(PollId poll_id) { return; } - auto full_message_id = server_poll_messages_[poll_id].get_random(); - LOG(INFO) << "Fetching results of " << poll_id << " from " << full_message_id; + auto message_full_id = server_poll_messages_[poll_id].get_random(); + LOG(INFO) << "Fetching results of " << poll_id << " from " << message_full_id; auto query_promise = PromiseCreator::lambda([actor_id = actor_id(this), poll_id, generation = current_generation_]( Result> &&result) { send_closure(actor_id, &PollManager::on_get_poll_results, poll_id, generation, std::move(result)); }); - td_->create_handler(std::move(query_promise))->send(poll_id, full_message_id); + td_->create_handler(std::move(query_promise))->send(poll_id, message_full_id); } void PollManager::on_close_poll_timeout(PollId poll_id) { @@ -1458,7 +1458,7 @@ void PollManager::on_online() { return; } - server_poll_messages_.foreach([&](const PollId &poll_id, WaitFreeHashSet &) { + server_poll_messages_.foreach([&](const PollId &poll_id, WaitFreeHashSet &) { if (update_poll_timeout_.has_timeout(poll_id.get())) { auto timeout = Random::fast(3, 30); LOG(INFO) << "Schedule updating of " << poll_id << " in " << timeout; @@ -1911,13 +1911,13 @@ void PollManager::on_binlog_events(vector &&events) { SetPollAnswerLogEvent log_event; log_event_parse(log_event, event.get_data()).ensure(); - auto dialog_id = log_event.full_message_id_.get_dialog_id(); + auto dialog_id = log_event.message_full_id_.get_dialog_id(); Dependencies dependencies; dependencies.add_dialog_dependencies(dialog_id); // do not load the dialog itself dependencies.resolve_force(td_, "SetPollAnswerLogEvent"); - do_set_poll_answer(log_event.poll_id_, log_event.full_message_id_, std::move(log_event.options_), event.id_, + do_set_poll_answer(log_event.poll_id_, log_event.message_full_id_, std::move(log_event.options_), event.id_, Auto()); break; } @@ -1930,13 +1930,13 @@ void PollManager::on_binlog_events(vector &&events) { StopPollLogEvent log_event; log_event_parse(log_event, event.get_data()).ensure(); - auto dialog_id = log_event.full_message_id_.get_dialog_id(); + auto dialog_id = log_event.message_full_id_.get_dialog_id(); Dependencies dependencies; dependencies.add_dialog_dependencies(dialog_id); // do not load the dialog itself dependencies.resolve_force(td_, "StopPollLogEvent"); - do_stop_poll(log_event.poll_id_, log_event.full_message_id_, nullptr, event.id_, Auto()); + do_stop_poll(log_event.poll_id_, log_event.message_full_id_, nullptr, event.id_, Auto()); break; } default: diff --git a/td/telegram/PollManager.h b/td/telegram/PollManager.h index 60f70cc80..751623b98 100644 --- a/td/telegram/PollManager.h +++ b/td/telegram/PollManager.h @@ -8,8 +8,8 @@ #include "td/telegram/ChannelId.h" #include "td/telegram/DialogId.h" -#include "td/telegram/FullMessageId.h" #include "td/telegram/MessageEntity.h" +#include "td/telegram/MessageFullId.h" #include "td/telegram/MinChannel.h" #include "td/telegram/net/NetQuery.h" #include "td/telegram/PollId.h" @@ -53,9 +53,9 @@ class PollManager final : public Actor { bool is_quiz, int32 correct_option_id, FormattedText &&explanation, int32 open_period, int32 close_date, bool is_closed); - void register_poll(PollId poll_id, FullMessageId full_message_id, const char *source); + void register_poll(PollId poll_id, MessageFullId message_full_id, const char *source); - void unregister_poll(PollId poll_id, FullMessageId full_message_id, const char *source); + void unregister_poll(PollId poll_id, MessageFullId message_full_id, const char *source); bool get_poll_is_closed(PollId poll_id) const; @@ -63,13 +63,13 @@ class PollManager final : public Actor { string get_poll_search_text(PollId poll_id) const; - void set_poll_answer(PollId poll_id, FullMessageId full_message_id, vector &&option_ids, + void set_poll_answer(PollId poll_id, MessageFullId message_full_id, vector &&option_ids, Promise &&promise); - void get_poll_voters(PollId poll_id, FullMessageId full_message_id, int32 option_id, int32 offset, int32 limit, + void get_poll_voters(PollId poll_id, MessageFullId message_full_id, int32 option_id, int32 offset, int32 limit, Promise> &&promise); - void stop_poll(PollId poll_id, FullMessageId full_message_id, unique_ptr &&reply_markup, + void stop_poll(PollId poll_id, MessageFullId message_full_id, unique_ptr &&reply_markup, Promise &&promise); void stop_local_poll(PollId poll_id); @@ -199,7 +199,7 @@ class PollManager final : public Actor { void on_get_poll_results(PollId poll_id, uint64 generation, Result> result); - void do_set_poll_answer(PollId poll_id, FullMessageId full_message_id, vector &&options, uint64 log_event_id, + void do_set_poll_answer(PollId poll_id, MessageFullId message_full_id, vector &&options, uint64 log_event_id, Promise &&promise); void on_set_poll_answer(PollId poll_id, uint64 generation, Result> &&result); @@ -218,10 +218,10 @@ class PollManager final : public Actor { void on_get_poll_voters(PollId poll_id, int32 option_id, string offset, int32 limit, Result> &&result); - void do_stop_poll(PollId poll_id, FullMessageId full_message_id, unique_ptr &&reply_markup, + void do_stop_poll(PollId poll_id, MessageFullId message_full_id, unique_ptr &&reply_markup, uint64 log_event_id, Promise &&promise); - void on_stop_poll_finished(PollId poll_id, FullMessageId full_message_id, uint64 log_event_id, Result &&result, + void on_stop_poll_finished(PollId poll_id, MessageFullId message_full_id, uint64 log_event_id, Result &&result, Promise &&promise); void forget_local_poll(PollId poll_id); @@ -232,8 +232,8 @@ class PollManager final : public Actor { WaitFreeHashMap, PollIdHash> polls_; - WaitFreeHashMap, PollIdHash> server_poll_messages_; - WaitFreeHashMap, PollIdHash> other_poll_messages_; + WaitFreeHashMap, PollIdHash> server_poll_messages_; + WaitFreeHashMap, PollIdHash> other_poll_messages_; struct PendingPollAnswer { vector options_; diff --git a/td/telegram/StatisticsManager.cpp b/td/telegram/StatisticsManager.cpp index d31a7dd01..5198c6f83 100644 --- a/td/telegram/StatisticsManager.cpp +++ b/td/telegram/StatisticsManager.cpp @@ -330,34 +330,34 @@ void StatisticsManager::send_get_channel_stats_query(DcId dc_id, ChannelId chann } void StatisticsManager::get_channel_message_statistics( - FullMessageId full_message_id, bool is_dark, Promise> &&promise) { - auto dc_id_promise = PromiseCreator::lambda([actor_id = actor_id(this), full_message_id, is_dark, + MessageFullId message_full_id, bool is_dark, Promise> &&promise) { + auto dc_id_promise = PromiseCreator::lambda([actor_id = actor_id(this), message_full_id, is_dark, promise = std::move(promise)](Result r_dc_id) mutable { if (r_dc_id.is_error()) { return promise.set_error(r_dc_id.move_as_error()); } send_closure(actor_id, &StatisticsManager::send_get_channel_message_stats_query, r_dc_id.move_as_ok(), - full_message_id, is_dark, std::move(promise)); + message_full_id, is_dark, std::move(promise)); }); - td_->contacts_manager_->get_channel_statistics_dc_id(full_message_id.get_dialog_id(), false, + td_->contacts_manager_->get_channel_statistics_dc_id(message_full_id.get_dialog_id(), false, std::move(dc_id_promise)); } void StatisticsManager::send_get_channel_message_stats_query( - DcId dc_id, FullMessageId full_message_id, bool is_dark, + DcId dc_id, MessageFullId message_full_id, bool is_dark, Promise> &&promise) { TRY_STATUS_PROMISE(promise, G()->close_status()); - auto dialog_id = full_message_id.get_dialog_id(); - if (!td_->messages_manager_->have_message_force(full_message_id, "send_get_channel_message_stats_query")) { + auto dialog_id = message_full_id.get_dialog_id(); + if (!td_->messages_manager_->have_message_force(message_full_id, "send_get_channel_message_stats_query")) { return promise.set_error(Status::Error(400, "Message not found")); } - if (!td_->messages_manager_->can_get_message_statistics(full_message_id)) { + if (!td_->messages_manager_->can_get_message_statistics(message_full_id)) { return promise.set_error(Status::Error(400, "Message statistics is inaccessible")); } CHECK(dialog_id.get_type() == DialogType::Channel); td_->create_handler(std::move(promise)) - ->send(dialog_id.get_channel_id(), full_message_id.get_message_id(), is_dark, dc_id); + ->send(dialog_id.get_channel_id(), message_full_id.get_message_id(), is_dark, dc_id); } void StatisticsManager::load_statistics_graph(DialogId dialog_id, string token, int64 x, diff --git a/td/telegram/StatisticsManager.h b/td/telegram/StatisticsManager.h index 32bef5e66..e54b144a3 100644 --- a/td/telegram/StatisticsManager.h +++ b/td/telegram/StatisticsManager.h @@ -8,7 +8,7 @@ #include "td/telegram/ChannelId.h" #include "td/telegram/DialogId.h" -#include "td/telegram/FullMessageId.h" +#include "td/telegram/MessageFullId.h" #include "td/telegram/net/DcId.h" #include "td/telegram/td_api.h" @@ -28,7 +28,7 @@ class StatisticsManager final : public Actor { void get_channel_statistics(DialogId dialog_id, bool is_dark, Promise> &&promise); - void get_channel_message_statistics(FullMessageId full_message_id, bool is_dark, + void get_channel_message_statistics(MessageFullId message_full_id, bool is_dark, Promise> &&promise); void load_statistics_graph(DialogId dialog_id, string token, int64 x, @@ -40,7 +40,7 @@ class StatisticsManager final : public Actor { void send_get_channel_stats_query(DcId dc_id, ChannelId channel_id, bool is_dark, Promise> &&promise); - void send_get_channel_message_stats_query(DcId dc_id, FullMessageId full_message_id, bool is_dark, + void send_get_channel_message_stats_query(DcId dc_id, MessageFullId message_full_id, bool is_dark, Promise> &&promise); void send_load_async_graph_query(DcId dc_id, string token, int64 x, diff --git a/td/telegram/StickersManager.cpp b/td/telegram/StickersManager.cpp index 9c853dc5c..ea2462c55 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -1904,13 +1904,13 @@ void StickersManager::on_load_special_sticker_set(const SpecialStickerSetType &t reset_to_empty(pending_get_animated_emoji_click_stickers_); for (auto &pending_request : pending_get_requests) { choose_animated_emoji_click_sticker(sticker_set, std::move(pending_request.message_text_), - pending_request.full_message_id_, pending_request.start_time_, + pending_request.message_full_id_, pending_request.start_time_, std::move(pending_request.promise_)); } auto pending_click_requests = std::move(pending_on_animated_emoji_message_clicked_); reset_to_empty(pending_on_animated_emoji_message_clicked_); for (auto &pending_request : pending_click_requests) { - schedule_update_animated_emoji_clicked(sticker_set, pending_request.emoji_, pending_request.full_message_id_, + schedule_update_animated_emoji_clicked(sticker_set, pending_request.emoji_, pending_request.message_full_id_, std::move(pending_request.clicks_)); } return; @@ -1924,11 +1924,11 @@ void StickersManager::on_load_special_sticker_set(const SpecialStickerSetType &t return; } - vector full_message_ids; - it->second.foreach([&](const FullMessageId &full_message_id) { full_message_ids.push_back(full_message_id); }); - CHECK(!full_message_ids.empty()); - for (const auto &full_message_id : full_message_ids) { - td_->messages_manager_->on_external_update_message_content(full_message_id); + vector message_full_ids; + it->second.foreach([&](const MessageFullId &message_full_id) { message_full_ids.push_back(message_full_id); }); + CHECK(!message_full_ids.empty()); + for (const auto &message_full_id : message_full_ids) { + td_->messages_manager_->on_external_update_message_content(message_full_id); } } @@ -5602,7 +5602,7 @@ void StickersManager::on_update_sticker_sets(StickerType sticker_type) { void StickersManager::try_update_animated_emoji_messages() { auto sticker_set = get_animated_emoji_sticker_set(); - vector full_message_ids; + vector message_full_ids; for (auto &it : emoji_messages_) { auto new_animated_sticker = get_animated_emoji_sticker(sticker_set, it.first); auto new_sound_file_id = get_animated_emoji_sound_file_id(it.first); @@ -5610,12 +5610,12 @@ void StickersManager::try_update_animated_emoji_messages() { (new_animated_sticker.first.is_valid() && new_sound_file_id != it.second->sound_file_id_)) { it.second->animated_emoji_sticker_ = new_animated_sticker; it.second->sound_file_id_ = new_sound_file_id; - it.second->full_message_ids_.foreach( - [&](const FullMessageId &full_message_id) { full_message_ids.push_back(full_message_id); }); + it.second->message_full_ids_.foreach( + [&](const MessageFullId &message_full_id) { message_full_ids.push_back(message_full_id); }); } } - for (const auto &full_message_id : full_message_ids) { - td_->messages_manager_->on_external_update_message_content(full_message_id); + for (const auto &message_full_id : message_full_ids) { + td_->messages_manager_->on_external_update_message_content(message_full_id); } } @@ -5625,86 +5625,86 @@ void StickersManager::try_update_custom_emoji_messages(CustomEmojiId custom_emoj return; } - vector full_message_ids; + vector message_full_ids; auto new_sticker_id = get_custom_animated_emoji_sticker_id(custom_emoji_id); if (new_sticker_id != it->second->sticker_id_) { it->second->sticker_id_ = new_sticker_id; - it->second->full_message_ids_.foreach( - [&](const FullMessageId &full_message_id) { full_message_ids.push_back(full_message_id); }); + it->second->message_full_ids_.foreach( + [&](const MessageFullId &message_full_id) { message_full_ids.push_back(message_full_id); }); } - for (const auto &full_message_id : full_message_ids) { - td_->messages_manager_->on_external_update_message_content(full_message_id); + for (const auto &message_full_id : message_full_ids) { + td_->messages_manager_->on_external_update_message_content(message_full_id); } } void StickersManager::try_update_premium_gift_messages() { auto sticker_set = get_premium_gift_sticker_set(); - vector full_message_ids; + vector message_full_ids; for (auto &it : premium_gift_messages_) { auto new_sticker_id = get_premium_gift_option_sticker_id(sticker_set, it.first); if (new_sticker_id != it.second->sticker_id_) { it.second->sticker_id_ = new_sticker_id; - for (const auto &full_message_id : it.second->full_message_ids_) { - full_message_ids.push_back(full_message_id); + for (const auto &message_full_id : it.second->message_full_ids_) { + message_full_ids.push_back(message_full_id); } } } - for (const auto &full_message_id : full_message_ids) { - td_->messages_manager_->on_external_update_message_content(full_message_id); + for (const auto &message_full_id : message_full_ids) { + td_->messages_manager_->on_external_update_message_content(message_full_id); } } -void StickersManager::register_premium_gift(int32 months, FullMessageId full_message_id, const char *source) { +void StickersManager::register_premium_gift(int32 months, MessageFullId message_full_id, const char *source) { if (td_->auth_manager_->is_bot() || months == 0) { return; } - LOG(INFO) << "Register premium gift for " << months << " months from " << full_message_id << " from " << source; + LOG(INFO) << "Register premium gift for " << months << " months from " << message_full_id << " from " << source; auto &premium_gift_messages_ptr = premium_gift_messages_[months]; if (premium_gift_messages_ptr == nullptr) { premium_gift_messages_ptr = make_unique(); } auto &premium_gift_messages = *premium_gift_messages_ptr; - if (premium_gift_messages.full_message_ids_.empty()) { + if (premium_gift_messages.message_full_ids_.empty()) { premium_gift_messages.sticker_id_ = get_premium_gift_option_sticker_id(months); } - bool is_inserted = premium_gift_messages.full_message_ids_.insert(full_message_id).second; - LOG_CHECK(is_inserted) << source << " " << months << " " << full_message_id; + bool is_inserted = premium_gift_messages.message_full_ids_.insert(message_full_id).second; + LOG_CHECK(is_inserted) << source << " " << months << " " << message_full_id; } -void StickersManager::unregister_premium_gift(int32 months, FullMessageId full_message_id, const char *source) { +void StickersManager::unregister_premium_gift(int32 months, MessageFullId message_full_id, const char *source) { if (td_->auth_manager_->is_bot() || months == 0) { return; } - LOG(INFO) << "Unregister premium gift for " << months << " months from " << full_message_id << " from " << source; + LOG(INFO) << "Unregister premium gift for " << months << " months from " << message_full_id << " from " << source; auto it = premium_gift_messages_.find(months); CHECK(it != premium_gift_messages_.end()); - auto &message_ids = it->second->full_message_ids_; - auto is_deleted = message_ids.erase(full_message_id) > 0; - LOG_CHECK(is_deleted) << source << " " << months << " " << full_message_id; + auto &message_ids = it->second->message_full_ids_; + auto is_deleted = message_ids.erase(message_full_id) > 0; + LOG_CHECK(is_deleted) << source << " " << months << " " << message_full_id; if (message_ids.empty()) { premium_gift_messages_.erase(it); } } -void StickersManager::register_dice(const string &emoji, int32 value, FullMessageId full_message_id, +void StickersManager::register_dice(const string &emoji, int32 value, MessageFullId message_full_id, const char *source) { CHECK(!emoji.empty()); if (td_->auth_manager_->is_bot()) { return; } - LOG(INFO) << "Register dice " << emoji << " with value " << value << " from " << full_message_id << " from " + LOG(INFO) << "Register dice " << emoji << " with value " << value << " from " << message_full_id << " from " << source; - dice_messages_[emoji].insert(full_message_id); + dice_messages_[emoji].insert(message_full_id); if (!td::contains(dice_emojis_, emoji)) { - if (full_message_id.get_message_id().is_any_server() && - full_message_id.get_dialog_id().get_type() != DialogType::SecretChat) { + if (message_full_id.get_message_id().is_any_server() && + message_full_id.get_dialog_id().get_type() != DialogType::SecretChat) { send_closure(G()->config_manager(), &ConfigManager::reget_app_config, Promise()); } return; @@ -5722,7 +5722,7 @@ void StickersManager::register_dice(const string &emoji, int32 value, FullMessag } if (need_load) { - LOG(INFO) << "Waiting for a dice sticker set needed in " << full_message_id; + LOG(INFO) << "Waiting for a dice sticker set needed in " << message_full_id; load_special_sticker_set(special_sticker_set); } else { // TODO reload once in a while @@ -5730,32 +5730,32 @@ void StickersManager::register_dice(const string &emoji, int32 value, FullMessag } } -void StickersManager::unregister_dice(const string &emoji, int32 value, FullMessageId full_message_id, +void StickersManager::unregister_dice(const string &emoji, int32 value, MessageFullId message_full_id, const char *source) { CHECK(!emoji.empty()); if (td_->auth_manager_->is_bot()) { return; } - LOG(INFO) << "Unregister dice " << emoji << " with value " << value << " from " << full_message_id << " from " + LOG(INFO) << "Unregister dice " << emoji << " with value " << value << " from " << message_full_id << " from " << source; auto &message_ids = dice_messages_[emoji]; - auto is_deleted = message_ids.erase(full_message_id) > 0; - LOG_CHECK(is_deleted) << source << " " << emoji << " " << value << " " << full_message_id; + auto is_deleted = message_ids.erase(message_full_id) > 0; + LOG_CHECK(is_deleted) << source << " " << emoji << " " << value << " " << message_full_id; if (message_ids.empty()) { dice_messages_.erase(emoji); } } -void StickersManager::register_emoji(const string &emoji, CustomEmojiId custom_emoji_id, FullMessageId full_message_id, +void StickersManager::register_emoji(const string &emoji, CustomEmojiId custom_emoji_id, MessageFullId message_full_id, const char *source) { CHECK(!emoji.empty()); if (td_->auth_manager_->is_bot()) { return; } - LOG(INFO) << "Register emoji " << emoji << " with " << custom_emoji_id << " from " << full_message_id << " from " + LOG(INFO) << "Register emoji " << emoji << " with " << custom_emoji_id << " from " << message_full_id << " from " << source; if (custom_emoji_id.is_valid()) { auto &emoji_messages_ptr = custom_emoji_messages_[custom_emoji_id]; @@ -5763,7 +5763,7 @@ void StickersManager::register_emoji(const string &emoji, CustomEmojiId custom_e emoji_messages_ptr = make_unique(); } auto &emoji_messages = *emoji_messages_ptr; - if (emoji_messages.full_message_ids_.empty()) { + if (emoji_messages.message_full_ids_.empty()) { if (!disable_animated_emojis_ && custom_emoji_to_sticker_id_.count(custom_emoji_id) == 0) { load_custom_emoji_sticker_from_database_force(custom_emoji_id); if (custom_emoji_to_sticker_id_.count(custom_emoji_id) == 0) { @@ -5772,7 +5772,7 @@ void StickersManager::register_emoji(const string &emoji, CustomEmojiId custom_e } emoji_messages.sticker_id_ = get_custom_animated_emoji_sticker_id(custom_emoji_id); } - emoji_messages.full_message_ids_.insert(full_message_id); + emoji_messages.message_full_ids_.insert(message_full_id); return; } @@ -5781,30 +5781,30 @@ void StickersManager::register_emoji(const string &emoji, CustomEmojiId custom_e emoji_messages_ptr = make_unique(); } auto &emoji_messages = *emoji_messages_ptr; - if (emoji_messages.full_message_ids_.empty()) { + if (emoji_messages.message_full_ids_.empty()) { emoji_messages.animated_emoji_sticker_ = get_animated_emoji_sticker(emoji); emoji_messages.sound_file_id_ = get_animated_emoji_sound_file_id(emoji); } - emoji_messages.full_message_ids_.insert(full_message_id); + emoji_messages.message_full_ids_.insert(message_full_id); } void StickersManager::unregister_emoji(const string &emoji, CustomEmojiId custom_emoji_id, - FullMessageId full_message_id, const char *source) { + MessageFullId message_full_id, const char *source) { CHECK(!emoji.empty()); if (td_->auth_manager_->is_bot()) { return; } - LOG(INFO) << "Unregister emoji " << emoji << " with " << custom_emoji_id << " from " << full_message_id << " from " + LOG(INFO) << "Unregister emoji " << emoji << " with " << custom_emoji_id << " from " << message_full_id << " from " << source; if (custom_emoji_id.is_valid()) { auto it = custom_emoji_messages_.find(custom_emoji_id); CHECK(it != custom_emoji_messages_.end()); - auto &full_message_ids = it->second->full_message_ids_; - auto is_deleted = full_message_ids.erase(full_message_id) > 0; - LOG_CHECK(is_deleted) << source << ' ' << custom_emoji_id << ' ' << full_message_id; + auto &message_full_ids = it->second->message_full_ids_; + auto is_deleted = message_full_ids.erase(message_full_id) > 0; + LOG_CHECK(is_deleted) << source << ' ' << custom_emoji_id << ' ' << message_full_id; - if (full_message_ids.empty()) { + if (message_full_ids.empty()) { custom_emoji_messages_.erase(it); } return; @@ -5812,11 +5812,11 @@ void StickersManager::unregister_emoji(const string &emoji, CustomEmojiId custom auto it = emoji_messages_.find(emoji); CHECK(it != emoji_messages_.end()); - auto &full_message_ids = it->second->full_message_ids_; - auto is_deleted = full_message_ids.erase(full_message_id) > 0; - LOG_CHECK(is_deleted) << source << ' ' << emoji << ' ' << full_message_id; + auto &message_full_ids = it->second->message_full_ids_; + auto is_deleted = message_full_ids.erase(message_full_id) > 0; + LOG_CHECK(is_deleted) << source << ' ' << emoji << ' ' << message_full_id; - if (full_message_ids.empty()) { + if (message_full_ids.empty()) { emoji_messages_.erase(it); } } @@ -6411,7 +6411,7 @@ void StickersManager::get_premium_gift_option_sticker(int32 month_count, bool is promise.set_value(get_sticker_object(get_premium_gift_option_sticker_id(sticker_set, month_count))); } -void StickersManager::get_animated_emoji_click_sticker(const string &message_text, FullMessageId full_message_id, +void StickersManager::get_animated_emoji_click_sticker(const string &message_text, MessageFullId message_full_id, Promise> &&promise) { if (disable_animated_emojis_ || td_->auth_manager_->is_bot()) { return promise.set_value(nullptr); @@ -6427,16 +6427,16 @@ void StickersManager::get_animated_emoji_click_sticker(const string &message_tex auto sticker_set = get_sticker_set(special_sticker_set.id_); CHECK(sticker_set != nullptr); if (sticker_set->was_loaded_) { - return choose_animated_emoji_click_sticker(sticker_set, message_text, full_message_id, Time::now(), + return choose_animated_emoji_click_sticker(sticker_set, message_text, message_full_id, Time::now(), std::move(promise)); } - LOG(INFO) << "Waiting for an emoji click sticker set needed in " << full_message_id; + LOG(INFO) << "Waiting for an emoji click sticker set needed in " << message_full_id; load_special_sticker_set(special_sticker_set); PendingGetAnimatedEmojiClickSticker pending_request; pending_request.message_text_ = message_text; - pending_request.full_message_id_ = full_message_id; + pending_request.message_full_id_ = message_full_id; pending_request.start_time_ = Time::now(); pending_request.promise_ = std::move(promise); pending_get_animated_emoji_click_stickers_.push_back(std::move(pending_request)); @@ -6470,7 +6470,7 @@ vector StickersManager::get_animated_emoji_click_stickers(const StickerS } void StickersManager::choose_animated_emoji_click_sticker(const StickerSet *sticker_set, string message_text, - FullMessageId full_message_id, double start_time, + MessageFullId message_full_id, double start_time, Promise> &&promise) { CHECK(sticker_set->was_loaded_); remove_emoji_modifiers_in_place(message_text); @@ -6483,7 +6483,7 @@ void StickersManager::choose_animated_emoji_click_sticker(const StickerSet *stic } auto now = Time::now(); - if (last_clicked_animated_emoji_ == message_text && last_clicked_animated_emoji_full_message_id_ == full_message_id && + if (last_clicked_animated_emoji_ == message_text && last_clicked_animated_emoji_message_full_id_ == message_full_id && next_click_animated_emoji_message_time_ >= now + 2 * MIN_ANIMATED_EMOJI_CLICK_DELAY) { return promise.set_value(nullptr); } @@ -6502,13 +6502,13 @@ void StickersManager::choose_animated_emoji_click_sticker(const StickerSet *stic } } if (found_stickers.empty()) { - LOG(INFO) << "There is no click effect for " << message_text << " from " << full_message_id; + LOG(INFO) << "There is no click effect for " << message_text << " from " << message_full_id; return promise.set_value(nullptr); } - if (last_clicked_animated_emoji_full_message_id_ != full_message_id) { + if (last_clicked_animated_emoji_message_full_id_ != message_full_id) { flush_pending_animated_emoji_clicks(); - last_clicked_animated_emoji_full_message_id_ = full_message_id; + last_clicked_animated_emoji_message_full_id_ = message_full_id; } if (last_clicked_animated_emoji_ != message_text) { pending_animated_emoji_clicks_.clear(); @@ -6567,16 +6567,16 @@ void StickersManager::flush_pending_animated_emoji_clicks() { } auto clicks = std::move(pending_animated_emoji_clicks_); pending_animated_emoji_clicks_.clear(); - auto full_message_id = last_clicked_animated_emoji_full_message_id_; - last_clicked_animated_emoji_full_message_id_ = FullMessageId(); + auto message_full_id = last_clicked_animated_emoji_message_full_id_; + last_clicked_animated_emoji_message_full_id_ = MessageFullId(); auto emoji = std::move(last_clicked_animated_emoji_); last_clicked_animated_emoji_.clear(); - if (td_->messages_manager_->is_message_edited_recently(full_message_id, 1)) { - // includes deleted full_message_id + if (td_->messages_manager_->is_message_edited_recently(message_full_id, 1)) { + // includes deleted message_full_id return; } - auto dialog_id = full_message_id.get_dialog_id(); + auto dialog_id = message_full_id.get_dialog_id(); auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); if (input_peer == nullptr) { return; @@ -6597,7 +6597,7 @@ void StickersManager::flush_pending_animated_emoji_clicks() { td_->create_handler()->send( dialog_id, std::move(input_peer), make_tl_object( - emoji, full_message_id.get_message_id().get_server_message_id().get(), + emoji, message_full_id.get_message_id().get_server_message_id().get(), make_tl_object(data))); on_send_animated_emoji_clicks(dialog_id, emoji); @@ -6641,7 +6641,7 @@ bool StickersManager::is_sent_animated_emoji_click(DialogId dialog_id, const str return false; } -Status StickersManager::on_animated_emoji_message_clicked(string &&emoji, FullMessageId full_message_id, string data) { +Status StickersManager::on_animated_emoji_message_clicked(string &&emoji, MessageFullId message_full_id, string data) { if (td_->auth_manager_->is_bot() || disable_animated_emojis_) { return Status::OK(); } @@ -6695,33 +6695,33 @@ Status StickersManager::on_animated_emoji_message_clicked(string &&emoji, FullMe auto sticker_set = get_sticker_set(special_sticker_set.id_); CHECK(sticker_set != nullptr); if (sticker_set->was_loaded_) { - schedule_update_animated_emoji_clicked(sticker_set, emoji, full_message_id, std::move(clicks)); + schedule_update_animated_emoji_clicked(sticker_set, emoji, message_full_id, std::move(clicks)); return Status::OK(); } } - LOG(INFO) << "Waiting for an emoji click sticker set needed in " << full_message_id; + LOG(INFO) << "Waiting for an emoji click sticker set needed in " << message_full_id; load_special_sticker_set(special_sticker_set); PendingOnAnimatedEmojiClicked pending_request; pending_request.emoji_ = std::move(emoji); - pending_request.full_message_id_ = full_message_id; + pending_request.message_full_id_ = message_full_id; pending_request.clicks_ = std::move(clicks); pending_on_animated_emoji_message_clicked_.push_back(std::move(pending_request)); return Status::OK(); } void StickersManager::schedule_update_animated_emoji_clicked(const StickerSet *sticker_set, Slice emoji, - FullMessageId full_message_id, + MessageFullId message_full_id, vector> clicks) { if (clicks.empty()) { return; } - if (td_->messages_manager_->is_message_edited_recently(full_message_id, 2)) { - // includes deleted full_message_id + if (td_->messages_manager_->is_message_edited_recently(message_full_id, 2)) { + // includes deleted message_full_id return; } - auto dialog_id = full_message_id.get_dialog_id(); + auto dialog_id = message_full_id.get_dialog_id(); if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Write)) { return; } @@ -6754,23 +6754,23 @@ void StickersManager::schedule_update_animated_emoji_clicked(const StickerSet *s } create_actor( "SendUpdateAnimatedEmojiClicked", start_time + click.second - now, - PromiseCreator::lambda([actor_id = actor_id(this), full_message_id, sticker_id](Result result) { - send_closure(actor_id, &StickersManager::send_update_animated_emoji_clicked, full_message_id, sticker_id); + PromiseCreator::lambda([actor_id = actor_id(this), message_full_id, sticker_id](Result result) { + send_closure(actor_id, &StickersManager::send_update_animated_emoji_clicked, message_full_id, sticker_id); })) .release(); } next_update_animated_emoji_clicked_time_ = start_time + clicks.back().second + MIN_ANIMATED_EMOJI_CLICK_DELAY; } -void StickersManager::send_update_animated_emoji_clicked(FullMessageId full_message_id, FileId sticker_id) { +void StickersManager::send_update_animated_emoji_clicked(MessageFullId message_full_id, FileId sticker_id) { if (G()->close_flag() || disable_animated_emojis_ || td_->auth_manager_->is_bot()) { return; } - if (td_->messages_manager_->is_message_edited_recently(full_message_id, 2)) { - // includes deleted full_message_id + if (td_->messages_manager_->is_message_edited_recently(message_full_id, 2)) { + // includes deleted message_full_id return; } - auto dialog_id = full_message_id.get_dialog_id(); + auto dialog_id = message_full_id.get_dialog_id(); if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Write)) { return; } @@ -6778,7 +6778,7 @@ void StickersManager::send_update_animated_emoji_clicked(FullMessageId full_mess send_closure(G()->td(), &Td::send_update, td_api::make_object( td_->messages_manager_->get_chat_id_object(dialog_id, "updateAnimatedEmojiMessageClicked"), - full_message_id.get_message_id().get(), get_sticker_object(sticker_id, false, true))); + message_full_id.get_message_id().get(), get_sticker_object(sticker_id, false, true))); } void StickersManager::view_featured_sticker_sets(const vector &sticker_set_ids) { diff --git a/td/telegram/StickersManager.h b/td/telegram/StickersManager.h index 71d105a3f..8ace863b6 100644 --- a/td/telegram/StickersManager.h +++ b/td/telegram/StickersManager.h @@ -13,7 +13,7 @@ #include "td/telegram/EmojiGroupType.h" #include "td/telegram/files/FileId.h" #include "td/telegram/files/FileSourceId.h" -#include "td/telegram/FullMessageId.h" +#include "td/telegram/MessageFullId.h" #include "td/telegram/PhotoFormat.h" #include "td/telegram/PhotoSize.h" #include "td/telegram/SecretInputMedia.h" @@ -103,18 +103,18 @@ class StickersManager final : public Actor { tl_object_ptr get_input_sticker_set(StickerSetId sticker_set_id) const; - void register_premium_gift(int32 months, FullMessageId full_message_id, const char *source); + void register_premium_gift(int32 months, MessageFullId message_full_id, const char *source); - void unregister_premium_gift(int32 months, FullMessageId full_message_id, const char *source); + void unregister_premium_gift(int32 months, MessageFullId message_full_id, const char *source); - void register_dice(const string &emoji, int32 value, FullMessageId full_message_id, const char *source); + void register_dice(const string &emoji, int32 value, MessageFullId message_full_id, const char *source); - void unregister_dice(const string &emoji, int32 value, FullMessageId full_message_id, const char *source); + void unregister_dice(const string &emoji, int32 value, MessageFullId message_full_id, const char *source); - void register_emoji(const string &emoji, CustomEmojiId custom_emoji_id, FullMessageId full_message_id, + void register_emoji(const string &emoji, CustomEmojiId custom_emoji_id, MessageFullId message_full_id, const char *source); - void unregister_emoji(const string &emoji, CustomEmojiId custom_emoji_id, FullMessageId full_message_id, + void unregister_emoji(const string &emoji, CustomEmojiId custom_emoji_id, MessageFullId message_full_id, const char *source); void get_animated_emoji(string emoji, bool is_recursive, @@ -140,14 +140,14 @@ class StickersManager final : public Actor { void get_premium_gift_option_sticker(int32 month_count, bool is_recursive, Promise> &&promise); - void get_animated_emoji_click_sticker(const string &message_text, FullMessageId full_message_id, + void get_animated_emoji_click_sticker(const string &message_text, MessageFullId message_full_id, Promise> &&promise); void on_send_animated_emoji_clicks(DialogId dialog_id, const string &emoji); bool is_sent_animated_emoji_click(DialogId dialog_id, const string &emoji); - Status on_animated_emoji_message_clicked(string &&emoji, FullMessageId full_message_id, string data); + Status on_animated_emoji_message_clicked(string &&emoji, MessageFullId message_full_id, string data); void create_sticker(FileId file_id, FileId premium_animation_file_id, string minithumbnail, PhotoSize thumbnail, Dimensions dimensions, tl_object_ptr sticker, @@ -531,14 +531,14 @@ class StickersManager final : public Actor { struct PendingGetAnimatedEmojiClickSticker { string message_text_; - FullMessageId full_message_id_; + MessageFullId message_full_id_; double start_time_ = 0; Promise> promise_; }; struct PendingOnAnimatedEmojiClicked { string emoji_; - FullMessageId full_message_id_; + MessageFullId message_full_id_; vector> clicks_; }; @@ -849,7 +849,7 @@ class StickersManager final : public Actor { vector get_animated_emoji_click_stickers(const StickerSet *sticker_set, Slice emoji) const; void choose_animated_emoji_click_sticker(const StickerSet *sticker_set, string message_text, - FullMessageId full_message_id, double start_time, + MessageFullId message_full_id, double start_time, Promise> &&promise); void send_click_animated_emoji_message_response(FileId sticker_id, @@ -859,10 +859,10 @@ class StickersManager final : public Actor { void flush_pending_animated_emoji_clicks(); - void schedule_update_animated_emoji_clicked(const StickerSet *sticker_set, Slice emoji, FullMessageId full_message_id, + void schedule_update_animated_emoji_clicked(const StickerSet *sticker_set, Slice emoji, MessageFullId message_full_id, vector> clicks); - void send_update_animated_emoji_clicked(FullMessageId full_message_id, FileId sticker_id); + void send_update_animated_emoji_clicked(MessageFullId message_full_id, FileId sticker_id); td_api::object_ptr get_update_dice_emojis_object() const; @@ -1067,7 +1067,7 @@ class StickersManager final : public Actor { vector pending_on_animated_emoji_message_clicked_; string last_clicked_animated_emoji_; - FullMessageId last_clicked_animated_emoji_full_message_id_; + MessageFullId last_clicked_animated_emoji_message_full_id_; std::vector> pending_animated_emoji_clicks_; struct SentAnimatedEmojiClicks { @@ -1090,22 +1090,22 @@ class StickersManager final : public Actor { FlatHashMap emoji_suggestions_urls_; struct GiftPremiumMessages { - FlatHashSet full_message_ids_; + FlatHashSet message_full_ids_; FileId sticker_id_; }; FlatHashMap> premium_gift_messages_; - FlatHashMap> dice_messages_; + FlatHashMap> dice_messages_; struct EmojiMessages { - WaitFreeHashSet full_message_ids_; + WaitFreeHashSet message_full_ids_; std::pair animated_emoji_sticker_; FileId sound_file_id_; }; FlatHashMap> emoji_messages_; struct CustomEmojiMessages { - WaitFreeHashSet full_message_ids_; + WaitFreeHashSet message_full_ids_; FileId sticker_id_; }; FlatHashMap, CustomEmojiIdHash> custom_emoji_messages_; diff --git a/td/telegram/StoryManager.cpp b/td/telegram/StoryManager.cpp index eec542cce..8495e2f92 100644 --- a/td/telegram/StoryManager.cpp +++ b/td/telegram/StoryManager.cpp @@ -3174,25 +3174,25 @@ int32 StoryManager::get_story_duration(StoryFullId story_full_id) const { return get_story_content_duration(td_, content); } -void StoryManager::register_story(StoryFullId story_full_id, FullMessageId full_message_id, const char *source) { +void StoryManager::register_story(StoryFullId story_full_id, MessageFullId message_full_id, const char *source) { if (td_->auth_manager_->is_bot()) { return; } CHECK(story_full_id.is_server()); - LOG(INFO) << "Register " << story_full_id << " from " << full_message_id << " from " << source; - story_messages_[story_full_id].insert(full_message_id); + LOG(INFO) << "Register " << story_full_id << " from " << message_full_id << " from " << source; + story_messages_[story_full_id].insert(message_full_id); } -void StoryManager::unregister_story(StoryFullId story_full_id, FullMessageId full_message_id, const char *source) { +void StoryManager::unregister_story(StoryFullId story_full_id, MessageFullId message_full_id, const char *source) { if (td_->auth_manager_->is_bot()) { return; } CHECK(story_full_id.is_server()); - LOG(INFO) << "Unregister " << story_full_id << " from " << full_message_id << " from " << source; + LOG(INFO) << "Unregister " << story_full_id << " from " << message_full_id << " from " << source; auto &message_ids = story_messages_[story_full_id]; - auto is_deleted = message_ids.erase(full_message_id) > 0; - LOG_CHECK(is_deleted) << source << ' ' << story_full_id << ' ' << full_message_id; + auto is_deleted = message_ids.erase(message_full_id) > 0; + LOG_CHECK(is_deleted) << source << ' ' << story_full_id << ' ' << message_full_id; if (message_ids.empty()) { story_messages_.erase(story_full_id); } @@ -3785,12 +3785,12 @@ void StoryManager::on_story_changed(StoryFullId story_full_id, const Story *stor send_closure_later(G()->web_pages_manager(), &WebPagesManager::on_story_changed, story_full_id); if (story_messages_.count(story_full_id) != 0) { - vector full_message_ids; + vector message_full_ids; story_messages_[story_full_id].foreach( - [&full_message_ids](const FullMessageId &full_message_id) { full_message_ids.push_back(full_message_id); }); - CHECK(!full_message_ids.empty()); - for (const auto &full_message_id : full_message_ids) { - td_->messages_manager_->on_external_update_message_content(full_message_id); + [&message_full_ids](const MessageFullId &message_full_id) { message_full_ids.push_back(message_full_id); }); + CHECK(!message_full_ids.empty()); + for (const auto &message_full_id : message_full_ids) { + td_->messages_manager_->on_external_update_message_content(message_full_id); } } } diff --git a/td/telegram/StoryManager.h b/td/telegram/StoryManager.h index 7268471eb..aa1f7a2f2 100644 --- a/td/telegram/StoryManager.h +++ b/td/telegram/StoryManager.h @@ -12,9 +12,9 @@ #include "td/telegram/DialogId.h" #include "td/telegram/files/FileId.h" #include "td/telegram/files/FileSourceId.h" -#include "td/telegram/FullMessageId.h" #include "td/telegram/MediaArea.h" #include "td/telegram/MessageEntity.h" +#include "td/telegram/MessageFullId.h" #include "td/telegram/ReactionType.h" #include "td/telegram/StoryDb.h" #include "td/telegram/StoryFullId.h" @@ -326,9 +326,9 @@ class StoryManager final : public Actor { int32 get_story_duration(StoryFullId story_full_id) const; - void register_story(StoryFullId story_full_id, FullMessageId full_message_id, const char *source); + void register_story(StoryFullId story_full_id, MessageFullId message_full_id, const char *source); - void unregister_story(StoryFullId story_full_id, FullMessageId full_message_id, const char *source); + void unregister_story(StoryFullId story_full_id, MessageFullId message_full_id, const char *source); td_api::object_ptr get_story_object(StoryFullId story_full_id) const; @@ -630,7 +630,7 @@ class StoryManager final : public Actor { WaitFreeHashSet failed_to_load_story_full_ids_; - WaitFreeHashMap, StoryFullIdHash> story_messages_; + WaitFreeHashMap, StoryFullIdHash> story_messages_; WaitFreeHashMap, DialogIdHash> active_stories_; diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 1c034aba1..06ef8084b 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -58,7 +58,6 @@ #include "td/telegram/files/FileType.h" #include "td/telegram/FolderId.h" #include "td/telegram/ForumTopicManager.h" -#include "td/telegram/FullMessageId.h" #include "td/telegram/GameManager.h" #include "td/telegram/Global.h" #include "td/telegram/GlobalPrivacySettings.h" @@ -73,6 +72,7 @@ #include "td/telegram/Logging.h" #include "td/telegram/MessageCopyOptions.h" #include "td/telegram/MessageEntity.h" +#include "td/telegram/MessageFullId.h" #include "td/telegram/MessageId.h" #include "td/telegram/MessageLinkInfo.h" #include "td/telegram/MessageReaction.h" @@ -949,19 +949,19 @@ class GetRecentlyOpenedChatsRequest final : public RequestActor<> { }; class GetMessageRequest final : public RequestOnceActor { - FullMessageId full_message_id_; + MessageFullId message_full_id_; void do_run(Promise &&promise) final { - td_->messages_manager_->get_message(full_message_id_, std::move(promise)); + td_->messages_manager_->get_message(message_full_id_, std::move(promise)); } void do_send_result() final { - send_result(td_->messages_manager_->get_message_object(full_message_id_, "GetMessageRequest")); + send_result(td_->messages_manager_->get_message_object(message_full_id_, "GetMessageRequest")); } public: GetMessageRequest(ActorShared td, uint64 request_id, int64 dialog_id, int64 message_id) - : RequestOnceActor(std::move(td), request_id), full_message_id_(DialogId(dialog_id), MessageId(message_id)) { + : RequestOnceActor(std::move(td), request_id), message_full_id_(DialogId(dialog_id), MessageId(message_id)) { } }; @@ -969,7 +969,7 @@ class GetRepliedMessageRequest final : public RequestOnceActor { DialogId dialog_id_; MessageId message_id_; - FullMessageId replied_message_id_; + MessageFullId replied_message_id_; void do_run(Promise &&promise) final { replied_message_id_ = @@ -1081,13 +1081,13 @@ class GetMessagesRequest final : public RequestOnceActor { }; class GetMessageEmbeddingCodeRequest final : public RequestActor<> { - FullMessageId full_message_id_; + MessageFullId message_full_id_; bool for_group_; string html_; void do_run(Promise &&promise) final { - html_ = td_->messages_manager_->get_message_embedding_code(full_message_id_, for_group_, std::move(promise)); + html_ = td_->messages_manager_->get_message_embedding_code(message_full_id_, for_group_, std::move(promise)); } void do_send_result() final { @@ -1098,7 +1098,7 @@ class GetMessageEmbeddingCodeRequest final : public RequestActor<> { GetMessageEmbeddingCodeRequest(ActorShared td, uint64 request_id, int64 dialog_id, int64 message_id, bool for_group) : RequestActor(std::move(td), request_id) - , full_message_id_(DialogId(dialog_id), MessageId(message_id)) + , message_full_id_(DialogId(dialog_id), MessageId(message_id)) , for_group_(for_group) { } }; @@ -1158,17 +1158,17 @@ class GetDialogBoostLinkInfoRequest final : public RequestActor reply_markup_; tl_object_ptr input_message_content_; void do_run(Promise &&promise) final { - td_->messages_manager_->edit_message_text(full_message_id_, std::move(reply_markup_), + td_->messages_manager_->edit_message_text(message_full_id_, std::move(reply_markup_), std::move(input_message_content_), std::move(promise)); } void do_send_result() final { - send_result(td_->messages_manager_->get_message_object(full_message_id_, "EditMessageTextRequest")); + send_result(td_->messages_manager_->get_message_object(message_full_id_, "EditMessageTextRequest")); } public: @@ -1176,26 +1176,26 @@ class EditMessageTextRequest final : public RequestOnceActor { tl_object_ptr reply_markup, tl_object_ptr input_message_content) : RequestOnceActor(std::move(td), request_id) - , full_message_id_(DialogId(dialog_id), MessageId(message_id)) + , message_full_id_(DialogId(dialog_id), MessageId(message_id)) , reply_markup_(std::move(reply_markup)) , input_message_content_(std::move(input_message_content)) { } }; class EditMessageLiveLocationRequest final : public RequestOnceActor { - FullMessageId full_message_id_; + MessageFullId message_full_id_; tl_object_ptr reply_markup_; tl_object_ptr location_; int32 heading_; int32 proximity_alert_radius_; void do_run(Promise &&promise) final { - td_->messages_manager_->edit_message_live_location(full_message_id_, std::move(reply_markup_), std::move(location_), + td_->messages_manager_->edit_message_live_location(message_full_id_, std::move(reply_markup_), std::move(location_), heading_, proximity_alert_radius_, std::move(promise)); } void do_send_result() final { - send_result(td_->messages_manager_->get_message_object(full_message_id_, "EditMessageLiveLocationRequest")); + send_result(td_->messages_manager_->get_message_object(message_full_id_, "EditMessageLiveLocationRequest")); } public: @@ -1203,7 +1203,7 @@ class EditMessageLiveLocationRequest final : public RequestOnceActor { tl_object_ptr reply_markup, tl_object_ptr location, int32 heading, int32 proximity_alert_radius) : RequestOnceActor(std::move(td), request_id) - , full_message_id_(DialogId(dialog_id), MessageId(message_id)) + , message_full_id_(DialogId(dialog_id), MessageId(message_id)) , reply_markup_(std::move(reply_markup)) , location_(std::move(location)) , heading_(heading) @@ -1212,17 +1212,17 @@ class EditMessageLiveLocationRequest final : public RequestOnceActor { }; class EditMessageMediaRequest final : public RequestOnceActor { - FullMessageId full_message_id_; + MessageFullId message_full_id_; tl_object_ptr reply_markup_; tl_object_ptr input_message_content_; void do_run(Promise &&promise) final { - td_->messages_manager_->edit_message_media(full_message_id_, std::move(reply_markup_), + td_->messages_manager_->edit_message_media(message_full_id_, std::move(reply_markup_), std::move(input_message_content_), std::move(promise)); } void do_send_result() final { - send_result(td_->messages_manager_->get_message_object(full_message_id_, "EditMessageMediaRequest")); + send_result(td_->messages_manager_->get_message_object(message_full_id_, "EditMessageMediaRequest")); } public: @@ -1230,24 +1230,24 @@ class EditMessageMediaRequest final : public RequestOnceActor { tl_object_ptr reply_markup, tl_object_ptr input_message_content) : RequestOnceActor(std::move(td), request_id) - , full_message_id_(DialogId(dialog_id), MessageId(message_id)) + , message_full_id_(DialogId(dialog_id), MessageId(message_id)) , reply_markup_(std::move(reply_markup)) , input_message_content_(std::move(input_message_content)) { } }; class EditMessageCaptionRequest final : public RequestOnceActor { - FullMessageId full_message_id_; + MessageFullId message_full_id_; tl_object_ptr reply_markup_; tl_object_ptr caption_; void do_run(Promise &&promise) final { - td_->messages_manager_->edit_message_caption(full_message_id_, std::move(reply_markup_), std::move(caption_), + td_->messages_manager_->edit_message_caption(message_full_id_, std::move(reply_markup_), std::move(caption_), std::move(promise)); } void do_send_result() final { - send_result(td_->messages_manager_->get_message_object(full_message_id_, "EditMessageCaptionRequest")); + send_result(td_->messages_manager_->get_message_object(message_full_id_, "EditMessageCaptionRequest")); } public: @@ -1255,29 +1255,29 @@ class EditMessageCaptionRequest final : public RequestOnceActor { tl_object_ptr reply_markup, tl_object_ptr caption) : RequestOnceActor(std::move(td), request_id) - , full_message_id_(DialogId(dialog_id), MessageId(message_id)) + , message_full_id_(DialogId(dialog_id), MessageId(message_id)) , reply_markup_(std::move(reply_markup)) , caption_(std::move(caption)) { } }; class EditMessageReplyMarkupRequest final : public RequestOnceActor { - FullMessageId full_message_id_; + MessageFullId message_full_id_; tl_object_ptr reply_markup_; void do_run(Promise &&promise) final { - td_->messages_manager_->edit_message_reply_markup(full_message_id_, std::move(reply_markup_), std::move(promise)); + td_->messages_manager_->edit_message_reply_markup(message_full_id_, std::move(reply_markup_), std::move(promise)); } void do_send_result() final { - send_result(td_->messages_manager_->get_message_object(full_message_id_, "EditMessageReplyMarkupRequest")); + send_result(td_->messages_manager_->get_message_object(message_full_id_, "EditMessageReplyMarkupRequest")); } public: EditMessageReplyMarkupRequest(ActorShared td, uint64 request_id, int64 dialog_id, int64 message_id, tl_object_ptr reply_markup) : RequestOnceActor(std::move(td), request_id) - , full_message_id_(DialogId(dialog_id), MessageId(message_id)) + , message_full_id_(DialogId(dialog_id), MessageId(message_id)) , reply_markup_(std::move(reply_markup)) { } }; @@ -1536,14 +1536,14 @@ class SearchCallMessagesRequest final : public RequestActor<> { }; class GetActiveLiveLocationMessagesRequest final : public RequestActor<> { - vector full_message_ids_; + vector message_full_ids_; void do_run(Promise &&promise) final { - full_message_ids_ = td_->messages_manager_->get_active_live_location_messages(std::move(promise)); + message_full_ids_ = td_->messages_manager_->get_active_live_location_messages(std::move(promise)); } void do_send_result() final { - send_result(td_->messages_manager_->get_messages_object(-1, full_message_ids_, true, + send_result(td_->messages_manager_->get_messages_object(-1, message_full_ids_, true, "GetActiveLiveLocationMessagesRequest")); } @@ -4772,9 +4772,9 @@ void Td::on_request(uint64 id, const td_api::getMessage &request) { } void Td::on_request(uint64 id, const td_api::getMessageLocally &request) { - FullMessageId full_message_id(DialogId(request.chat_id_), MessageId(request.message_id_)); + MessageFullId message_full_id(DialogId(request.chat_id_), MessageId(request.message_id_)); send_closure(actor_id(this), &Td::send_result, id, - messages_manager_->get_message_object(full_message_id, "getMessageLocally")); + messages_manager_->get_message_object(message_full_id, "getMessageLocally")); } void Td::on_request(uint64 id, const td_api::getRepliedMessage &request) { @@ -7140,7 +7140,7 @@ void Td::on_request(uint64 id, const td_api::addFileToDownloads &request) { } CREATE_REQUEST_PROMISE(); messages_manager_->add_message_file_to_downloads( - FullMessageId(DialogId(request.chat_id_), MessageId(request.message_id_)), FileId(request.file_id_, 0), + MessageFullId(DialogId(request.chat_id_), MessageId(request.message_id_)), FileId(request.file_id_, 0), request.priority_, std::move(promise)); } diff --git a/td/telegram/TranscriptionInfo.cpp b/td/telegram/TranscriptionInfo.cpp index 825818218..fda092c54 100644 --- a/td/telegram/TranscriptionInfo.cpp +++ b/td/telegram/TranscriptionInfo.cpp @@ -23,16 +23,16 @@ class TranscribeAudioQuery final : public Td::ResultHandler { std::function>)> handler_; public: - void send(FullMessageId full_message_id, + void send(MessageFullId message_full_id, std::function>)> &&handler) { - dialog_id_ = full_message_id.get_dialog_id(); + dialog_id_ = message_full_id.get_dialog_id(); handler_ = std::move(handler); auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read); if (input_peer == nullptr) { return on_error(Status::Error(400, "Can't access the chat")); } send_query(G()->net_query_creator().create(telegram_api::messages_transcribeAudio( - std::move(input_peer), full_message_id.get_message_id().get_server_message_id().get()))); + std::move(input_peer), message_full_id.get_message_id().get_server_message_id().get()))); } void on_result(BufferSlice packet) final { @@ -67,14 +67,14 @@ class RateTranscribedAudioQuery final : public Td::ResultHandler { explicit RateTranscribedAudioQuery(Promise &&promise) : promise_(std::move(promise)) { } - void send(FullMessageId full_message_id, int64 transcription_id, bool is_good) { - dialog_id_ = full_message_id.get_dialog_id(); + void send(MessageFullId message_full_id, int64 transcription_id, bool is_good) { + dialog_id_ = message_full_id.get_dialog_id(); auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read); if (input_peer == nullptr) { return on_error(Status::Error(400, "Can't access the chat")); } send_query(G()->net_query_creator().create(telegram_api::messages_rateTranscribedAudio( - std::move(input_peer), full_message_id.get_message_id().get_server_message_id().get(), transcription_id, + std::move(input_peer), message_full_id.get_message_id().get_server_message_id().get(), transcription_id, is_good))); } @@ -96,7 +96,7 @@ class RateTranscribedAudioQuery final : public Td::ResultHandler { }; bool TranscriptionInfo::recognize_speech( - Td *td, FullMessageId full_message_id, Promise &&promise, + Td *td, MessageFullId message_full_id, Promise &&promise, std::function>)> &&handler) { if (is_transcribed_) { promise.set_value(Unit()); @@ -105,7 +105,7 @@ bool TranscriptionInfo::recognize_speech( speech_recognition_queries_.push_back(std::move(promise)); if (speech_recognition_queries_.size() == 1) { last_transcription_error_ = Status::OK(); - td->create_handler()->send(full_message_id, std::move(handler)); + td->create_handler()->send(message_full_id, std::move(handler)); return true; } return false; @@ -151,13 +151,13 @@ vector> TranscriptionInfo::on_failed_transcription(Status &&error) return promises; } -void TranscriptionInfo::rate_speech_recognition(Td *td, FullMessageId full_message_id, bool is_good, +void TranscriptionInfo::rate_speech_recognition(Td *td, MessageFullId message_full_id, bool is_good, Promise &&promise) const { if (!is_transcribed_) { return promise.set_value(Unit()); } CHECK(transcription_id_ != 0); - td->create_handler(std::move(promise))->send(full_message_id, transcription_id_, is_good); + td->create_handler(std::move(promise))->send(message_full_id, transcription_id_, is_good); } unique_ptr TranscriptionInfo::copy_if_transcribed(const unique_ptr &info) { diff --git a/td/telegram/TranscriptionInfo.h b/td/telegram/TranscriptionInfo.h index 2a2bfedcd..5fce1562d 100644 --- a/td/telegram/TranscriptionInfo.h +++ b/td/telegram/TranscriptionInfo.h @@ -6,7 +6,7 @@ // #pragma once -#include "td/telegram/FullMessageId.h" +#include "td/telegram/MessageFullId.h" #include "td/telegram/td_api.h" #include "td/telegram/telegram_api.h" @@ -35,7 +35,7 @@ class TranscriptionInfo { } bool recognize_speech( - Td *td, FullMessageId full_message_id, Promise &&promise, + Td *td, MessageFullId message_full_id, Promise &&promise, std::function>)> &&handler); vector> on_final_transcription(string &&text, int64 transcription_id); @@ -44,7 +44,7 @@ class TranscriptionInfo { vector> on_failed_transcription(Status &&error); - void rate_speech_recognition(Td *td, FullMessageId full_message_id, bool is_good, Promise &&promise) const; + void rate_speech_recognition(Td *td, MessageFullId message_full_id, bool is_good, Promise &&promise) const; static unique_ptr copy_if_transcribed(const unique_ptr &info); diff --git a/td/telegram/UpdatesManager.cpp b/td/telegram/UpdatesManager.cpp index dc7d06025..963bac01c 100644 --- a/td/telegram/UpdatesManager.cpp +++ b/td/telegram/UpdatesManager.cpp @@ -1429,7 +1429,7 @@ const telegram_api::Message *UpdatesManager::get_message_by_random_id(const tele } const telegram_api::Message *result = nullptr; - FullMessageId full_message_id(dialog_id, MessageId(ServerMessageId(message_id))); + MessageFullId message_full_id(dialog_id, MessageId(ServerMessageId(message_id))); for (auto &update : *updates) { auto constructor_id = update->get_id(); const tl_object_ptr *message = nullptr; @@ -1438,7 +1438,7 @@ const telegram_api::Message *UpdatesManager::get_message_by_random_id(const tele } else if (constructor_id == telegram_api::updateNewChannelMessage::ID) { message = &static_cast(update.get())->message_; } - if (message != nullptr && FullMessageId::get_full_message_id(*message, false) == full_message_id) { + if (message != nullptr && MessageFullId::get_message_full_id(*message, false) == message_full_id) { if (result != nullptr) { return nullptr; } @@ -1619,7 +1619,7 @@ vector UpdatesManager::get_chat_dialog_ids(const telegram_api::Updates } int32 UpdatesManager::get_update_edit_message_pts(const telegram_api::Updates *updates_ptr, - FullMessageId full_message_id) { + MessageFullId message_full_id) { int32 pts = 0; auto updates = get_updates(updates_ptr); if (updates != nullptr) { @@ -1628,24 +1628,24 @@ int32 UpdatesManager::get_update_edit_message_pts(const telegram_api::Updates *u switch (update_ptr->get_id()) { case telegram_api::updateEditMessage::ID: { auto update = static_cast(update_ptr.get()); - if (FullMessageId::get_full_message_id(update->message_, false) == full_message_id) { + if (MessageFullId::get_message_full_id(update->message_, false) == message_full_id) { return update->pts_; } return 0; } case telegram_api::updateEditChannelMessage::ID: { auto update = static_cast(update_ptr.get()); - if (FullMessageId::get_full_message_id(update->message_, false) == full_message_id) { + if (MessageFullId::get_message_full_id(update->message_, false) == message_full_id) { return update->pts_; } return 0; } case telegram_api::updateNewScheduledMessage::ID: { auto update = static_cast(update_ptr.get()); - auto new_full_message_id = FullMessageId::get_full_message_id(update->message_, true); - if (new_full_message_id.get_dialog_id() == full_message_id.get_dialog_id()) { - auto new_message_id = new_full_message_id.get_message_id(); - auto old_message_id = full_message_id.get_message_id(); + auto new_message_full_id = MessageFullId::get_message_full_id(update->message_, true); + if (new_message_full_id.get_dialog_id() == message_full_id.get_dialog_id()) { + auto new_message_id = new_message_full_id.get_message_id(); + auto old_message_id = message_full_id.get_message_id(); if (new_message_id.is_valid_scheduled() && new_message_id.is_scheduled_server() && old_message_id.is_valid_scheduled() && old_message_id.is_scheduled_server() && old_message_id.get_scheduled_server_message_id() == @@ -1672,7 +1672,7 @@ int32 UpdatesManager::get_update_edit_message_pts(const telegram_api::Updates *u LOG(ERROR) << "Receive multiple edit message updates in " << to_string(*updates_ptr); pts = 0; } else if (pts == 0) { - LOG(ERROR) << "Receive no edit message updates for " << full_message_id << " in " << to_string(*updates_ptr); + LOG(ERROR) << "Receive no edit message updates for " << message_full_id << " in " << to_string(*updates_ptr); } return pts; } diff --git a/td/telegram/UpdatesManager.h b/td/telegram/UpdatesManager.h index c68126320..1e04723f9 100644 --- a/td/telegram/UpdatesManager.h +++ b/td/telegram/UpdatesManager.h @@ -9,8 +9,8 @@ #include "td/telegram/ChannelId.h" #include "td/telegram/ChatId.h" #include "td/telegram/DialogId.h" -#include "td/telegram/FullMessageId.h" #include "td/telegram/InputGroupCallId.h" +#include "td/telegram/MessageFullId.h" #include "td/telegram/MessageId.h" #include "td/telegram/PtsManager.h" #include "td/telegram/telegram_api.h" @@ -125,7 +125,7 @@ class UpdatesManager final : public Actor { static vector get_chat_dialog_ids(const telegram_api::Updates *updates_ptr); - static int32 get_update_edit_message_pts(const telegram_api::Updates *updates_ptr, FullMessageId full_message_id); + static int32 get_update_edit_message_pts(const telegram_api::Updates *updates_ptr, MessageFullId message_full_id); using TranscribedAudioHandler = std::function>)>; diff --git a/td/telegram/VideoNotesManager.cpp b/td/telegram/VideoNotesManager.cpp index 1c377b927..b6fde75b9 100644 --- a/td/telegram/VideoNotesManager.cpp +++ b/td/telegram/VideoNotesManager.cpp @@ -170,40 +170,40 @@ void VideoNotesManager::create_video_note(FileId file_id, string minithumbnail, on_get_video_note(std::move(v), replace); } -void VideoNotesManager::register_video_note(FileId video_note_file_id, FullMessageId full_message_id, +void VideoNotesManager::register_video_note(FileId video_note_file_id, MessageFullId message_full_id, const char *source) { - if (full_message_id.get_message_id().is_scheduled() || !full_message_id.get_message_id().is_server() || + if (message_full_id.get_message_id().is_scheduled() || !message_full_id.get_message_id().is_server() || td_->auth_manager_->is_bot()) { return; } - LOG(INFO) << "Register video note " << video_note_file_id << " from " << full_message_id << " from " << source; + LOG(INFO) << "Register video note " << video_note_file_id << " from " << message_full_id << " from " << source; CHECK(video_note_file_id.is_valid()); - bool is_inserted = video_note_messages_[video_note_file_id].insert(full_message_id).second; - LOG_CHECK(is_inserted) << source << ' ' << video_note_file_id << ' ' << full_message_id; - is_inserted = message_video_notes_.emplace(full_message_id, video_note_file_id).second; + bool is_inserted = video_note_messages_[video_note_file_id].insert(message_full_id).second; + LOG_CHECK(is_inserted) << source << ' ' << video_note_file_id << ' ' << message_full_id; + is_inserted = message_video_notes_.emplace(message_full_id, video_note_file_id).second; CHECK(is_inserted); } -void VideoNotesManager::unregister_video_note(FileId video_note_file_id, FullMessageId full_message_id, +void VideoNotesManager::unregister_video_note(FileId video_note_file_id, MessageFullId message_full_id, const char *source) { - if (full_message_id.get_message_id().is_scheduled() || !full_message_id.get_message_id().is_server() || + if (message_full_id.get_message_id().is_scheduled() || !message_full_id.get_message_id().is_server() || td_->auth_manager_->is_bot()) { return; } - LOG(INFO) << "Unregister video note " << video_note_file_id << " from " << full_message_id << " from " << source; + LOG(INFO) << "Unregister video note " << video_note_file_id << " from " << message_full_id << " from " << source; CHECK(video_note_file_id.is_valid()); auto &message_ids = video_note_messages_[video_note_file_id]; - auto is_deleted = message_ids.erase(full_message_id) > 0; - LOG_CHECK(is_deleted) << source << ' ' << video_note_file_id << ' ' << full_message_id; + auto is_deleted = message_ids.erase(message_full_id) > 0; + LOG_CHECK(is_deleted) << source << ' ' << video_note_file_id << ' ' << message_full_id; if (message_ids.empty()) { video_note_messages_.erase(video_note_file_id); } - is_deleted = message_video_notes_.erase(full_message_id) > 0; + is_deleted = message_video_notes_.erase(message_full_id) > 0; CHECK(is_deleted); } -void VideoNotesManager::recognize_speech(FullMessageId full_message_id, Promise &&promise) { - auto it = message_video_notes_.find(full_message_id); +void VideoNotesManager::recognize_speech(MessageFullId message_full_id, Promise &&promise) { + auto it = message_video_notes_.find(message_full_id); CHECK(it != message_video_notes_.end()); auto file_id = it->second; @@ -217,7 +217,7 @@ void VideoNotesManager::recognize_speech(FullMessageId full_message_id, Promise< file_id](Result> r_update) { send_closure(actor_id, &VideoNotesManager::on_transcribed_audio_update, file_id, true, std::move(r_update)); }; - if (video_note->transcription_info->recognize_speech(td_, full_message_id, std::move(promise), std::move(handler))) { + if (video_note->transcription_info->recognize_speech(td_, message_full_id, std::move(promise), std::move(handler))) { on_video_note_transcription_updated(file_id); } } @@ -265,8 +265,8 @@ void VideoNotesManager::on_transcribed_audio_update( void VideoNotesManager::on_video_note_transcription_updated(FileId file_id) { auto it = video_note_messages_.find(file_id); if (it != video_note_messages_.end()) { - for (const auto &full_message_id : it->second) { - td_->messages_manager_->on_external_update_message_content(full_message_id); + for (const auto &message_full_id : it->second) { + td_->messages_manager_->on_external_update_message_content(message_full_id); } } } @@ -274,14 +274,14 @@ void VideoNotesManager::on_video_note_transcription_updated(FileId file_id) { void VideoNotesManager::on_video_note_transcription_completed(FileId file_id) { auto it = video_note_messages_.find(file_id); if (it != video_note_messages_.end()) { - for (const auto &full_message_id : it->second) { - td_->messages_manager_->on_update_message_content(full_message_id); + for (const auto &message_full_id : it->second) { + td_->messages_manager_->on_update_message_content(message_full_id); } } } -void VideoNotesManager::rate_speech_recognition(FullMessageId full_message_id, bool is_good, Promise &&promise) { - auto it = message_video_notes_.find(full_message_id); +void VideoNotesManager::rate_speech_recognition(MessageFullId message_full_id, bool is_good, Promise &&promise) { + auto it = message_video_notes_.find(message_full_id); CHECK(it != message_video_notes_.end()); auto file_id = it->second; @@ -290,7 +290,7 @@ void VideoNotesManager::rate_speech_recognition(FullMessageId full_message_id, b if (video_note->transcription_info == nullptr) { return promise.set_value(Unit()); } - video_note->transcription_info->rate_speech_recognition(td_, full_message_id, is_good, std::move(promise)); + video_note->transcription_info->rate_speech_recognition(td_, message_full_id, is_good, std::move(promise)); } SecretInputMedia VideoNotesManager::get_secret_input_media(FileId video_note_file_id, diff --git a/td/telegram/VideoNotesManager.h b/td/telegram/VideoNotesManager.h index 0c4eb3bc1..c7de5796e 100644 --- a/td/telegram/VideoNotesManager.h +++ b/td/telegram/VideoNotesManager.h @@ -8,7 +8,7 @@ #include "td/telegram/Dimensions.h" #include "td/telegram/files/FileId.h" -#include "td/telegram/FullMessageId.h" +#include "td/telegram/MessageFullId.h" #include "td/telegram/PhotoSize.h" #include "td/telegram/SecretInputMedia.h" #include "td/telegram/td_api.h" @@ -45,13 +45,13 @@ class VideoNotesManager final : public Actor { void create_video_note(FileId file_id, string minithumbnail, PhotoSize thumbnail, int32 duration, Dimensions dimensions, string waveform, bool replace); - void register_video_note(FileId video_note_file_id, FullMessageId full_message_id, const char *source); + void register_video_note(FileId video_note_file_id, MessageFullId message_full_id, const char *source); - void unregister_video_note(FileId video_note_file_id, FullMessageId full_message_id, const char *source); + void unregister_video_note(FileId video_note_file_id, MessageFullId message_full_id, const char *source); - void recognize_speech(FullMessageId full_message_id, Promise &&promise); + void recognize_speech(MessageFullId message_full_id, Promise &&promise); - void rate_speech_recognition(FullMessageId full_message_id, bool is_good, Promise &&promise); + void rate_speech_recognition(MessageFullId message_full_id, bool is_good, Promise &&promise); tl_object_ptr get_input_media(FileId file_id, tl_object_ptr input_file, @@ -108,8 +108,8 @@ class VideoNotesManager final : public Actor { WaitFreeHashMap, FileIdHash> video_notes_; - FlatHashMap, FileIdHash> video_note_messages_; - FlatHashMap message_video_notes_; + FlatHashMap, FileIdHash> video_note_messages_; + FlatHashMap message_video_notes_; }; } // namespace td diff --git a/td/telegram/VoiceNotesManager.cpp b/td/telegram/VoiceNotesManager.cpp index f7520951f..678b1f5ed 100644 --- a/td/telegram/VoiceNotesManager.cpp +++ b/td/telegram/VoiceNotesManager.cpp @@ -134,40 +134,40 @@ void VoiceNotesManager::create_voice_note(FileId file_id, string mime_type, int3 on_get_voice_note(std::move(v), replace); } -void VoiceNotesManager::register_voice_note(FileId voice_note_file_id, FullMessageId full_message_id, +void VoiceNotesManager::register_voice_note(FileId voice_note_file_id, MessageFullId message_full_id, const char *source) { - if (full_message_id.get_message_id().is_scheduled() || !full_message_id.get_message_id().is_server() || + if (message_full_id.get_message_id().is_scheduled() || !message_full_id.get_message_id().is_server() || td_->auth_manager_->is_bot()) { return; } - LOG(INFO) << "Register voice note " << voice_note_file_id << " from " << full_message_id << " from " << source; + LOG(INFO) << "Register voice note " << voice_note_file_id << " from " << message_full_id << " from " << source; CHECK(voice_note_file_id.is_valid()); - bool is_inserted = voice_note_messages_[voice_note_file_id].insert(full_message_id).second; - LOG_CHECK(is_inserted) << source << ' ' << voice_note_file_id << ' ' << full_message_id; - is_inserted = message_voice_notes_.emplace(full_message_id, voice_note_file_id).second; + bool is_inserted = voice_note_messages_[voice_note_file_id].insert(message_full_id).second; + LOG_CHECK(is_inserted) << source << ' ' << voice_note_file_id << ' ' << message_full_id; + is_inserted = message_voice_notes_.emplace(message_full_id, voice_note_file_id).second; CHECK(is_inserted); } -void VoiceNotesManager::unregister_voice_note(FileId voice_note_file_id, FullMessageId full_message_id, +void VoiceNotesManager::unregister_voice_note(FileId voice_note_file_id, MessageFullId message_full_id, const char *source) { - if (full_message_id.get_message_id().is_scheduled() || !full_message_id.get_message_id().is_server() || + if (message_full_id.get_message_id().is_scheduled() || !message_full_id.get_message_id().is_server() || td_->auth_manager_->is_bot()) { return; } - LOG(INFO) << "Unregister voice note " << voice_note_file_id << " from " << full_message_id << " from " << source; + LOG(INFO) << "Unregister voice note " << voice_note_file_id << " from " << message_full_id << " from " << source; CHECK(voice_note_file_id.is_valid()); auto &message_ids = voice_note_messages_[voice_note_file_id]; - auto is_deleted = message_ids.erase(full_message_id) > 0; - LOG_CHECK(is_deleted) << source << ' ' << voice_note_file_id << ' ' << full_message_id; + auto is_deleted = message_ids.erase(message_full_id) > 0; + LOG_CHECK(is_deleted) << source << ' ' << voice_note_file_id << ' ' << message_full_id; if (message_ids.empty()) { voice_note_messages_.erase(voice_note_file_id); } - is_deleted = message_voice_notes_.erase(full_message_id) > 0; + is_deleted = message_voice_notes_.erase(message_full_id) > 0; CHECK(is_deleted); } -void VoiceNotesManager::recognize_speech(FullMessageId full_message_id, Promise &&promise) { - auto it = message_voice_notes_.find(full_message_id); +void VoiceNotesManager::recognize_speech(MessageFullId message_full_id, Promise &&promise) { + auto it = message_voice_notes_.find(message_full_id); CHECK(it != message_voice_notes_.end()); auto file_id = it->second; @@ -181,7 +181,7 @@ void VoiceNotesManager::recognize_speech(FullMessageId full_message_id, Promise< file_id](Result> r_update) { send_closure(actor_id, &VoiceNotesManager::on_transcribed_audio_update, file_id, true, std::move(r_update)); }; - if (voice_note->transcription_info->recognize_speech(td_, full_message_id, std::move(promise), std::move(handler))) { + if (voice_note->transcription_info->recognize_speech(td_, message_full_id, std::move(promise), std::move(handler))) { on_voice_note_transcription_updated(file_id); } } @@ -229,8 +229,8 @@ void VoiceNotesManager::on_transcribed_audio_update( void VoiceNotesManager::on_voice_note_transcription_updated(FileId file_id) { auto it = voice_note_messages_.find(file_id); if (it != voice_note_messages_.end()) { - for (const auto &full_message_id : it->second) { - td_->messages_manager_->on_external_update_message_content(full_message_id); + for (const auto &message_full_id : it->second) { + td_->messages_manager_->on_external_update_message_content(message_full_id); } } } @@ -238,14 +238,14 @@ void VoiceNotesManager::on_voice_note_transcription_updated(FileId file_id) { void VoiceNotesManager::on_voice_note_transcription_completed(FileId file_id) { auto it = voice_note_messages_.find(file_id); if (it != voice_note_messages_.end()) { - for (const auto &full_message_id : it->second) { - td_->messages_manager_->on_update_message_content(full_message_id); + for (const auto &message_full_id : it->second) { + td_->messages_manager_->on_update_message_content(message_full_id); } } } -void VoiceNotesManager::rate_speech_recognition(FullMessageId full_message_id, bool is_good, Promise &&promise) { - auto it = message_voice_notes_.find(full_message_id); +void VoiceNotesManager::rate_speech_recognition(MessageFullId message_full_id, bool is_good, Promise &&promise) { + auto it = message_voice_notes_.find(message_full_id); CHECK(it != message_voice_notes_.end()); auto file_id = it->second; @@ -254,7 +254,7 @@ void VoiceNotesManager::rate_speech_recognition(FullMessageId full_message_id, b if (voice_note->transcription_info == nullptr) { return promise.set_value(Unit()); } - voice_note->transcription_info->rate_speech_recognition(td_, full_message_id, is_good, std::move(promise)); + voice_note->transcription_info->rate_speech_recognition(td_, message_full_id, is_good, std::move(promise)); } SecretInputMedia VoiceNotesManager::get_secret_input_media(FileId voice_note_file_id, diff --git a/td/telegram/VoiceNotesManager.h b/td/telegram/VoiceNotesManager.h index ca609ec4a..f4c8bd978 100644 --- a/td/telegram/VoiceNotesManager.h +++ b/td/telegram/VoiceNotesManager.h @@ -7,7 +7,7 @@ #pragma once #include "td/telegram/files/FileId.h" -#include "td/telegram/FullMessageId.h" +#include "td/telegram/MessageFullId.h" #include "td/telegram/SecretInputMedia.h" #include "td/telegram/td_api.h" #include "td/telegram/telegram_api.h" @@ -41,13 +41,13 @@ class VoiceNotesManager final : public Actor { void create_voice_note(FileId file_id, string mime_type, int32 duration, string waveform, bool replace); - void register_voice_note(FileId voice_note_file_id, FullMessageId full_message_id, const char *source); + void register_voice_note(FileId voice_note_file_id, MessageFullId message_full_id, const char *source); - void unregister_voice_note(FileId voice_note_file_id, FullMessageId full_message_id, const char *source); + void unregister_voice_note(FileId voice_note_file_id, MessageFullId message_full_id, const char *source); - void recognize_speech(FullMessageId full_message_id, Promise &&promise); + void recognize_speech(MessageFullId message_full_id, Promise &&promise); - void rate_speech_recognition(FullMessageId full_message_id, bool is_good, Promise &&promise); + void rate_speech_recognition(MessageFullId message_full_id, bool is_good, Promise &&promise); tl_object_ptr get_input_media(FileId file_id, tl_object_ptr input_file) const; @@ -97,8 +97,8 @@ class VoiceNotesManager final : public Actor { WaitFreeHashMap, FileIdHash> voice_notes_; - FlatHashMap, FileIdHash> voice_note_messages_; - FlatHashMap message_voice_notes_; + FlatHashMap, FileIdHash> voice_note_messages_; + FlatHashMap message_voice_notes_; }; } // namespace td diff --git a/td/telegram/WebPagesManager.cpp b/td/telegram/WebPagesManager.cpp index 723ca5374..9232c5a84 100644 --- a/td/telegram/WebPagesManager.cpp +++ b/td/telegram/WebPagesManager.cpp @@ -769,30 +769,30 @@ void WebPagesManager::on_get_web_page_by_url(const string &url, WebPageId web_pa cached_web_page_id = web_page_id; } -void WebPagesManager::register_web_page(WebPageId web_page_id, FullMessageId full_message_id, const char *source) { +void WebPagesManager::register_web_page(WebPageId web_page_id, MessageFullId message_full_id, const char *source) { if (!web_page_id.is_valid()) { return; } - LOG(INFO) << "Register " << web_page_id << " from " << full_message_id << " from " << source; - bool is_inserted = web_page_messages_[web_page_id].insert(full_message_id).second; - LOG_CHECK(is_inserted) << source << " " << web_page_id << " " << full_message_id; + LOG(INFO) << "Register " << web_page_id << " from " << message_full_id << " from " << source; + bool is_inserted = web_page_messages_[web_page_id].insert(message_full_id).second; + LOG_CHECK(is_inserted) << source << " " << web_page_id << " " << message_full_id; if (!td_->auth_manager_->is_bot() && !have_web_page_force(web_page_id)) { - LOG(INFO) << "Waiting for " << web_page_id << " needed in " << full_message_id; + LOG(INFO) << "Waiting for " << web_page_id << " needed in " << message_full_id; pending_web_pages_timeout_.add_timeout_in(web_page_id.get(), 1.0); } } -void WebPagesManager::unregister_web_page(WebPageId web_page_id, FullMessageId full_message_id, const char *source) { +void WebPagesManager::unregister_web_page(WebPageId web_page_id, MessageFullId message_full_id, const char *source) { if (!web_page_id.is_valid()) { return; } - LOG(INFO) << "Unregister " << web_page_id << " from " << full_message_id << " from " << source; + LOG(INFO) << "Unregister " << web_page_id << " from " << message_full_id << " from " << source; auto &message_ids = web_page_messages_[web_page_id]; - auto is_deleted = message_ids.erase(full_message_id) > 0; - LOG_CHECK(is_deleted) << source << " " << web_page_id << " " << full_message_id; + auto is_deleted = message_ids.erase(message_full_id) > 0; + LOG_CHECK(is_deleted) << source << " " << web_page_id << " " << message_full_id; if (message_ids.empty()) { web_page_messages_.erase(web_page_id); @@ -1357,27 +1357,27 @@ void WebPagesManager::on_web_page_changed(WebPageId web_page_id, bool have_web_p LOG(INFO) << "Updated " << web_page_id; auto it = web_page_messages_.find(web_page_id); if (it != web_page_messages_.end()) { - vector full_message_ids; - for (const auto &full_message_id : it->second) { - full_message_ids.push_back(full_message_id); + vector message_full_ids; + for (const auto &message_full_id : it->second) { + message_full_ids.push_back(message_full_id); } - CHECK(!full_message_ids.empty()); - for (const auto &full_message_id : full_message_ids) { + CHECK(!message_full_ids.empty()); + for (const auto &message_full_id : message_full_ids) { if (!have_web_page) { - td_->messages_manager_->delete_pending_message_web_page(full_message_id); + td_->messages_manager_->delete_pending_message_web_page(message_full_id); } else { - td_->messages_manager_->on_external_update_message_content(full_message_id); + td_->messages_manager_->on_external_update_message_content(message_full_id); } } - bool is_ok = (have_web_page ? web_page_messages_[web_page_id].size() == full_message_ids.size() + bool is_ok = (have_web_page ? web_page_messages_[web_page_id].size() == message_full_ids.size() : web_page_messages_.count(web_page_id) == 0); if (!is_ok) { - vector new_full_message_ids; - for (const auto &full_message_id : web_page_messages_[web_page_id]) { - new_full_message_ids.push_back(full_message_id); + vector new_message_full_ids; + for (const auto &message_full_id : web_page_messages_[web_page_id]) { + new_message_full_ids.push_back(message_full_id); } - LOG_CHECK(is_ok) << have_web_page << ' ' << full_message_ids << ' ' << new_full_message_ids; + LOG_CHECK(is_ok) << have_web_page << ' ' << message_full_ids << ' ' << new_message_full_ids; } } auto get_it = pending_get_web_pages_.find(web_page_id); @@ -1436,16 +1436,16 @@ void WebPagesManager::on_pending_web_page_timeout(WebPageId web_page_id) { int32 count = 0; auto it = web_page_messages_.find(web_page_id); if (it != web_page_messages_.end()) { - vector full_message_ids; - for (const auto &full_message_id : it->second) { - if (full_message_id.get_dialog_id().get_type() != DialogType::SecretChat) { - full_message_ids.push_back(full_message_id); + vector message_full_ids; + for (const auto &message_full_id : it->second) { + if (message_full_id.get_dialog_id().get_type() != DialogType::SecretChat) { + message_full_ids.push_back(message_full_id); } count++; } - if (!full_message_ids.empty()) { + if (!message_full_ids.empty()) { send_closure_later(G()->messages_manager(), &MessagesManager::get_messages_from_server, - std::move(full_message_ids), Promise(), "on_pending_web_page_timeout", nullptr); + std::move(message_full_ids), Promise(), "on_pending_web_page_timeout", nullptr); } } auto get_it = pending_get_web_pages_.find(web_page_id); diff --git a/td/telegram/WebPagesManager.h b/td/telegram/WebPagesManager.h index 2846d85ab..357be3db0 100644 --- a/td/telegram/WebPagesManager.h +++ b/td/telegram/WebPagesManager.h @@ -9,7 +9,7 @@ #include "td/telegram/DialogId.h" #include "td/telegram/files/FileId.h" #include "td/telegram/files/FileSourceId.h" -#include "td/telegram/FullMessageId.h" +#include "td/telegram/MessageFullId.h" #include "td/telegram/SecretInputMedia.h" #include "td/telegram/StoryFullId.h" #include "td/telegram/td_api.h" @@ -52,9 +52,9 @@ class WebPagesManager final : public Actor { void on_get_web_page_instant_view_view_count(WebPageId web_page_id, int32 view_count); - void register_web_page(WebPageId web_page_id, FullMessageId full_message_id, const char *source); + void register_web_page(WebPageId web_page_id, MessageFullId message_full_id, const char *source); - void unregister_web_page(WebPageId web_page_id, FullMessageId full_message_id, const char *source); + void unregister_web_page(WebPageId web_page_id, MessageFullId message_full_id, const char *source); bool have_web_page(WebPageId web_page_id) const; @@ -183,7 +183,7 @@ class WebPagesManager final : public Actor { }; FlatHashMap load_web_page_instant_view_queries_; - FlatHashMap, WebPageIdHash> web_page_messages_; + FlatHashMap, WebPageIdHash> web_page_messages_; FlatHashMap>>>, WebPageIdHash> pending_get_web_pages_;