From 49372ab4c2d0920d9e0beb638abd0c89846566da Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 20 Mar 2024 18:54:04 +0300 Subject: [PATCH] Add message.is_from_offline flag. --- td/generate/scheme/td_api.tl | 3 ++- td/telegram/MessagesManager.cpp | 34 ++++++++++++++++++++------------- td/telegram/MessagesManager.h | 2 ++ 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index eb2d35357..d0d142691 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -1411,6 +1411,7 @@ inputMessageReplyToStory story_sender_chat_id:int53 story_id:int32 = InputMessag //@scheduling_state The scheduling state of the message; may be null if the message isn't scheduled //@is_outgoing True, if the message is outgoing //@is_pinned True, if the message is pinned +//@is_from_offline True, if the message was sent because of a scheduled action by the message sender, for example, as away, or greeting service message //@can_be_edited True, if the message can be edited. For live location and poll messages this fields shows whether editMessageLiveLocation or stopPoll can be used with this message by the application //@can_be_forwarded True, if the message can be forwarded //@can_be_replied_in_another_chat True, if the message can be replied in another chat or topic @@ -1448,7 +1449,7 @@ inputMessageReplyToStory story_sender_chat_id:int53 story_id:int32 = InputMessag //@restriction_reason If non-empty, contains a human-readable description of the reason why access to this message must be restricted //@content Content of the message //@reply_markup Reply markup for the message; may be null if none -message id:int53 sender_id:MessageSender chat_id:int53 sending_state:MessageSendingState scheduling_state:MessageSchedulingState is_outgoing:Bool is_pinned:Bool can_be_edited:Bool can_be_forwarded:Bool can_be_replied_in_another_chat:Bool can_be_saved:Bool can_be_deleted_only_for_self:Bool can_be_deleted_for_all_users:Bool can_get_added_reactions:Bool can_get_statistics:Bool can_get_message_thread:Bool can_get_read_date:Bool can_get_viewers:Bool can_get_media_timestamp_links:Bool can_report_reactions:Bool has_timestamped_media:Bool is_channel_post:Bool is_topic_message:Bool contains_unread_mention:Bool date:int32 edit_date:int32 forward_info:messageForwardInfo import_info:messageImportInfo interaction_info:messageInteractionInfo unread_reactions:vector reply_to:MessageReplyTo message_thread_id:int53 saved_messages_topic_id:int53 self_destruct_type:MessageSelfDestructType self_destruct_in:double auto_delete_in:double via_bot_user_id:int53 sender_business_bot_user_id:int53 sender_boost_count:int32 author_signature:string media_album_id:int64 restriction_reason:string content:MessageContent reply_markup:ReplyMarkup = Message; +message id:int53 sender_id:MessageSender chat_id:int53 sending_state:MessageSendingState scheduling_state:MessageSchedulingState is_outgoing:Bool is_pinned:Bool is_from_offline:Bool can_be_edited:Bool can_be_forwarded:Bool can_be_replied_in_another_chat:Bool can_be_saved:Bool can_be_deleted_only_for_self:Bool can_be_deleted_for_all_users:Bool can_get_added_reactions:Bool can_get_statistics:Bool can_get_message_thread:Bool can_get_read_date:Bool can_get_viewers:Bool can_get_media_timestamp_links:Bool can_report_reactions:Bool has_timestamped_media:Bool is_channel_post:Bool is_topic_message:Bool contains_unread_mention:Bool date:int32 edit_date:int32 forward_info:messageForwardInfo import_info:messageImportInfo interaction_info:messageInteractionInfo unread_reactions:vector reply_to:MessageReplyTo message_thread_id:int53 saved_messages_topic_id:int53 self_destruct_type:MessageSelfDestructType self_destruct_in:double auto_delete_in:double via_bot_user_id:int53 sender_business_bot_user_id:int53 sender_boost_count:int32 author_signature:string media_album_id:int64 restriction_reason:string content:MessageContent reply_markup:ReplyMarkup = Message; //@description Contains a list of messages @total_count Approximate total number of messages found @messages List of messages; messages may be null messages total_count:int32 messages:vector = Messages; diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index e85225803..dc43905ae 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -4188,6 +4188,7 @@ void MessagesManager::Message::store(StorerT &storer) const { STORE_FLAG(has_initial_top_thread_message_id); STORE_FLAG(has_sender_boost_count); STORE_FLAG(has_via_business_bot_user_id); + STORE_FLAG(is_from_offline); END_STORE_FLAGS(); } @@ -4456,6 +4457,7 @@ void MessagesManager::Message::parse(ParserT &parser) { PARSE_FLAG(has_initial_top_thread_message_id); PARSE_FLAG(has_sender_boost_count); PARSE_FLAG(has_via_business_bot_user_id); + PARSE_FLAG(is_from_offline); END_PARSE_FLAGS(); } @@ -13075,6 +13077,7 @@ MessagesManager::MessageInfo MessagesManager::parse_telegram_api_message( message_info.is_legacy = message->legacy_; message_info.hide_edit_date = message->edit_hide_; message_info.is_from_scheduled = message->from_scheduled_; + message_info.is_from_offline = message->offline_; message_info.is_pinned = message->pinned_; message_info.noforwards = message->noforwards_; message_info.has_mention = message->mentioned_; @@ -13402,6 +13405,7 @@ std::pair> MessagesManager::creat message->is_content_secret = is_content_secret; message->hide_edit_date = hide_edit_date; message->is_from_scheduled = message_info.is_from_scheduled; + message->is_from_offline = message_info.is_from_offline; message->is_pinned = is_pinned; message->noforwards = noforwards; message->interaction_info_update_date = G()->unix_time(); @@ -22671,10 +22675,10 @@ td_api::object_ptr MessagesManager::get_dialog_event_log_messag get_message_own_max_media_timestamp(m), m->invert_media, m->disable_web_page_preview); return td_api::make_object( m->message_id.get(), std::move(sender), get_chat_id_object(dialog_id, "get_dialog_event_log_message_object"), - nullptr, nullptr, m->is_outgoing, m->is_pinned, false, false, false, can_be_saved, false, false, false, false, - false, false, false, false, false, true, m->is_channel_post, m->is_topic_message, false, m->date, edit_date, - std::move(forward_info), std::move(import_info), std::move(interaction_info), Auto(), nullptr, 0, 0, nullptr, 0.0, - 0.0, via_bot_user_id, 0, m->sender_boost_count, m->author_signature, 0, + nullptr, nullptr, m->is_outgoing, m->is_pinned, m->is_from_offline, false, false, false, can_be_saved, false, + false, false, false, false, false, false, false, false, true, m->is_channel_post, m->is_topic_message, false, + m->date, edit_date, std::move(forward_info), std::move(import_info), std::move(interaction_info), Auto(), nullptr, + 0, 0, nullptr, 0.0, 0.0, via_bot_user_id, 0, m->sender_boost_count, m->author_signature, 0, get_restriction_reason_description(m->restriction_reasons), std::move(content), std::move(reply_markup)); } @@ -22739,11 +22743,12 @@ td_api::object_ptr MessagesManager::get_business_message_messag return td_api::make_object( m->message_id.get(), std::move(sender), get_chat_id_object(dialog_id, "get_business_message_message_object"), - nullptr, nullptr, m->is_outgoing, false, false, false, false, can_be_saved, false, false, false, false, false, - false, false, false, false, false, false, false, false, m->date, m->edit_date, std::move(forward_info), - std::move(import_info), nullptr, Auto(), std::move(reply_to), 0, 0, std::move(self_destruct_type), 0.0, 0.0, - via_bot_user_id, via_business_bot_user_id, 0, string(), m->media_album_id, - get_restriction_reason_description(m->restriction_reasons), std::move(content), std::move(reply_markup)); + nullptr, nullptr, m->is_outgoing, m->is_from_offline, false, false, false, false, can_be_saved, false, false, + false, false, false, false, false, false, false, false, false, false, false, m->date, m->edit_date, + std::move(forward_info), std::move(import_info), nullptr, Auto(), std::move(reply_to), 0, 0, + std::move(self_destruct_type), 0.0, 0.0, via_bot_user_id, via_business_bot_user_id, 0, string(), + m->media_album_id, get_restriction_reason_description(m->restriction_reasons), std::move(content), + std::move(reply_markup)); } td_api::object_ptr MessagesManager::get_message_object(MessageFullId message_full_id, @@ -22851,10 +22856,10 @@ td_api::object_ptr MessagesManager::get_message_object(DialogId return td_api::make_object( m->message_id.get(), std::move(sender), get_chat_id_object(dialog_id, "get_message_object"), - std::move(sending_state), std::move(scheduling_state), is_outgoing, m->is_pinned, can_be_edited, can_be_forwarded, - can_be_replied_in_another_chat, can_be_saved, can_delete_for_self, can_delete_for_all_users, - can_get_added_reactions, can_get_statistics, can_get_message_thread, can_get_read_date, can_get_viewers, - can_get_media_timestamp_links, can_report_reactions, has_timestamped_media, m->is_channel_post, + std::move(sending_state), std::move(scheduling_state), is_outgoing, m->is_pinned, m->is_from_offline, + can_be_edited, can_be_forwarded, can_be_replied_in_another_chat, can_be_saved, can_delete_for_self, + can_delete_for_all_users, can_get_added_reactions, can_get_statistics, can_get_message_thread, can_get_read_date, + can_get_viewers, can_get_media_timestamp_links, can_report_reactions, has_timestamped_media, m->is_channel_post, m->is_topic_message, m->contains_unread_mention, date, edit_date, std::move(forward_info), std::move(import_info), std::move(interaction_info), std::move(unread_reactions), std::move(reply_to), top_thread_message_id, td_->saved_messages_manager_->get_saved_messages_topic_id_object(m->saved_messages_topic_id), @@ -33902,6 +33907,9 @@ bool MessagesManager::update_message(Dialog *d, Message *old_message, unique_ptr // is_from_scheduled flag shouldn't be changed, because we are unable to show/hide message notification // old_message->is_from_scheduled = new_message->is_from_scheduled; } + if (old_message->is_from_offline != new_message->is_from_offline) { + old_message->is_from_offline = new_message->is_from_offline; + } if (old_message->edit_date > 0) { // inline keyboard can be edited diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index ec7e9128d..19b6c647c 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -1002,6 +1002,7 @@ class MessagesManager final : public Actor { bool is_legacy = false; bool hide_edit_date = false; bool is_from_scheduled = false; + bool is_from_offline = false; bool is_pinned = false; bool noforwards = false; bool has_mention = false; @@ -1060,6 +1061,7 @@ class MessagesManager final : public Actor { bool is_content_secret = false; // must be shown only while tapped bool is_mention_notification_disabled = false; bool is_from_scheduled = false; + bool is_from_offline = false; bool is_pinned = false; bool are_media_timestamp_entities_found = false; bool noforwards = false;