From 8552180f0d6cf67e6ddcde46ff25b40e6b887eff Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 17 Oct 2023 12:27:26 +0300 Subject: [PATCH] Add Message.invert_media flag. --- td/telegram/MessagesManager.cpp | 13 ++++++++++++- td/telegram/MessagesManager.h | 3 +++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index c3eb9c229..819f336b0 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -4744,6 +4744,7 @@ void MessagesManager::Message::store(StorerT &storer) const { STORE_FLAG(has_history_generation); STORE_FLAG(is_reply_to_story); STORE_FLAG(has_forward_origin); + STORE_FLAG(invert_media); END_STORE_FLAGS(); } @@ -4993,6 +4994,7 @@ void MessagesManager::Message::parse(ParserT &parser) { PARSE_FLAG(has_history_generation); PARSE_FLAG(is_reply_to_story); PARSE_FLAG(has_forward_origin); + PARSE_FLAG(invert_media); END_PARSE_FLAGS(); } @@ -13344,6 +13346,7 @@ void MessagesManager::on_message_ttl_expired_impl(Dialog *d, Message *m, bool is m->contains_mention = false; m->linked_top_thread_message_id = MessageId(); m->is_content_secret = false; + m->invert_media = false; } void MessagesManager::loop() { @@ -14262,6 +14265,7 @@ MessagesManager::MessageInfo MessagesManager::parse_telegram_api_message( message_info.noforwards = message->noforwards_; message_info.has_mention = message->mentioned_; message_info.has_unread_content = message->media_unread_; + message_info.invert_media = message->invert_media_; bool is_content_read = !message_info.has_unread_content; if (is_message_auto_read(message_info.dialog_id, message_info.is_outgoing)) { @@ -14536,6 +14540,7 @@ std::pair> MessagesManager::creat reply_to_story_full_id = StoryFullId(); noforwards = false; is_content_secret = false; + message_info.invert_media = false; } bool is_pinned = message_info.is_pinned; @@ -14586,6 +14591,7 @@ std::pair> MessagesManager::creat message->reply_info = std::move(reply_info); message->reactions = std::move(reactions); message->legacy_layer = (message_info.is_legacy ? MTPROTO_LAYER : 0); + message->invert_media = message_info.invert_media; message->content = std::move(message_info.content); message->reply_markup = get_reply_markup(std::move(message_info.reply_markup), td_->auth_manager_->is_bot(), false, message->contains_mention || dialog_type == DialogType::User); @@ -27363,6 +27369,9 @@ int32 MessagesManager::get_message_flags(const Message *m) { if (m->update_stickersets_order) { flags |= SEND_MESSAGE_FLAG_UPDATE_STICKER_SETS_ORDER; } + if (m->invert_media) { + flags |= SEND_MESSAGE_FLAG_INVERT_MEDIA; + } return flags; } @@ -35984,7 +35993,9 @@ bool MessagesManager::update_message(Dialog *d, Message *old_message, unique_ptr bool is_content_changed = false; if (update_message_content(dialog_id, old_message, std::move(new_message->content), message_id.is_yet_unsent() && new_message->edit_date == 0, is_message_in_dialog, - is_content_changed)) { + is_content_changed) || + old_message->invert_media != new_message->invert_media) { + old_message->invert_media = new_message->invert_media; send_update_message_content(d, old_message, is_message_in_dialog, "update_message"); need_send_update = true; } diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 4c7aa7d10..ef342233a 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -132,6 +132,7 @@ class MessagesManager final : public Actor { static constexpr int32 SEND_MESSAGE_FLAG_HAS_SEND_AS = 1 << 13; static constexpr int32 SEND_MESSAGE_FLAG_NOFORWARDS = 1 << 14; static constexpr int32 SEND_MESSAGE_FLAG_UPDATE_STICKER_SETS_ORDER = 1 << 15; + static constexpr int32 SEND_MESSAGE_FLAG_INVERT_MEDIA = 1 << 16; static constexpr int32 ONLINE_MEMBER_COUNT_CACHE_EXPIRE_TIME = 30 * 60; @@ -1074,6 +1075,7 @@ class MessagesManager final : public Actor { bool noforwards = false; bool has_mention = false; bool has_unread_content = false; + bool invert_media = false; unique_ptr content; tl_object_ptr reply_markup; @@ -1164,6 +1166,7 @@ class MessagesManager final : public Actor { bool is_pinned = false; bool are_media_timestamp_entities_found = false; bool noforwards = false; + bool invert_media = false; bool has_explicit_sender = false; // for send_message bool is_copy = false; // for send_message