From 46beb7d87318c0ac8de9af7223c2a7baf011ce50 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 8 Jul 2024 22:56:02 +0300 Subject: [PATCH] Add messageProperties.can_edit_scheduling_state. --- td/generate/scheme/td_api.tl | 5 +++-- td/telegram/MessagesManager.cpp | 14 +++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 84f94ab3b..a52bfcd06 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -3841,6 +3841,7 @@ inputMessageForwarded from_chat_id:int53 message_id:int53 in_game_share:Bool cop //@can_be_reported True, if the message can be reported using reportSupergroupSpam or reportChat //@can_be_saved True, if content of the message can be saved locally or copied using inputMessageForwarded or forwardMessages with copy options //@can_be_shared_in_story True, if the message can be shared in a story using inputStoryAreaTypeMessage +//@can_edit_scheduling_state True, if scheduling state of the message can be edited //@can_get_added_reactions True, if the list of added reactions is available using getMessageAddedReactions //@can_get_embedding_code True, if code for message embedding can be received using getMessageEmbeddingCode //@can_get_link True, if a link can be generated for the message using getMessageLink @@ -3851,7 +3852,7 @@ inputMessageForwarded from_chat_id:int53 message_id:int53 in_game_share:Bool cop //@can_get_viewers True, if chat members already viewed the message can be received through getMessageViewers //@can_report_reactions True, if reactions on the message can be reported through reportMessageReactions //@can_recognize_speech True, if speech can be recognized for the message through recognizeSpeech -messageProperties can_be_deleted_only_for_self:Bool can_be_deleted_for_all_users:Bool can_be_edited:Bool can_be_forwarded:Bool can_be_paid:Bool can_be_replied:Bool can_be_replied_in_another_chat:Bool can_be_reported:Bool can_be_saved:Bool can_be_shared_in_story:Bool can_get_added_reactions:Bool can_get_embedding_code:Bool can_get_link:Bool can_get_media_timestamp_links:Bool can_get_message_thread:Bool can_get_read_date:Bool can_get_statistics:Bool can_get_viewers:Bool can_report_reactions:Bool can_recognize_speech:Bool = MessageProperties; +messageProperties can_be_deleted_only_for_self:Bool can_be_deleted_for_all_users:Bool can_be_edited:Bool can_be_forwarded:Bool can_be_paid:Bool can_be_replied:Bool can_be_replied_in_another_chat:Bool can_be_reported:Bool can_be_saved:Bool can_be_shared_in_story:Bool can_edit_scheduling_state:Bool can_get_added_reactions:Bool can_get_embedding_code:Bool can_get_link:Bool can_get_media_timestamp_links:Bool can_get_message_thread:Bool can_get_read_date:Bool can_get_statistics:Bool can_get_viewers:Bool can_report_reactions:Bool can_recognize_speech:Bool = MessageProperties; //@class SearchMessagesFilter @description Represents a filter for message search results @@ -8641,7 +8642,7 @@ editInlineMessageReplyMarkup inline_message_id:string reply_markup:ReplyMarkup = //@description Edits the time when a scheduled message will be sent. Scheduling state of all messages in the same album or forwarded together with the message will be also changed //@chat_id The chat the message belongs to -//@message_id Identifier of the message +//@message_id Identifier of the message. Use messageProperties.can_edit_scheduling_state to check whether the message is suitable //@scheduling_state The new message scheduling state; pass null to send the message immediately editMessageSchedulingState chat_id:int53 message_id:int53 scheduling_state:MessageSchedulingState = Ok; diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index eaf206dfd..6ed93109c 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -17310,9 +17310,7 @@ void MessagesManager::get_message_properties(DialogId dialog_id, MessageId messa const Message *m = get_message_force(d, message_id, "get_message_properties"); if (m == nullptr) { if (message_id.is_valid_sponsored()) { - return promise.set_value(td_api::make_object( - false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false)); + return promise.set_value(td_api::make_object()); } return promise.set_error(Status::Error(400, "Message not found")); } @@ -17356,6 +17354,7 @@ void MessagesManager::get_message_properties(DialogId dialog_id, MessageId messa auto can_be_replied_in_another_chat = can_be_forwarded && m->message_id.is_server(); auto can_be_reported = dialog_type != DialogType::SecretChat && can_report_message(m->message_id).is_ok(); auto can_be_shared_in_story = can_share_message_in_story(dialog_id, m); + auto can_edit_scheduling_state = m->message_id.is_valid_scheduled() && m->message_id.is_scheduled_server(); 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_message_full_id(dialog_id, m, false).is_ok(); @@ -17368,9 +17367,10 @@ void MessagesManager::get_message_properties(DialogId dialog_id, MessageId messa auto can_recognize_speech = can_recognize_message_speech(dialog_id, m); promise.set_value(td_api::make_object( can_delete_for_self, can_delete_for_all_users, can_be_edited, can_be_forwarded, can_be_paid, can_be_replied, - can_be_replied_in_another_chat, can_be_reported, can_be_saved, can_be_shared_in_story, can_get_added_reactions, - can_get_embedding_code, can_get_link, can_get_media_timestamp_links, can_get_message_thread, can_get_read_date, - can_get_statistics, can_get_viewers, can_report_reactions, can_recognize_speech)); + can_be_replied_in_another_chat, can_be_reported, can_be_saved, can_be_shared_in_story, can_edit_scheduling_state, + can_get_added_reactions, can_get_embedding_code, can_get_link, can_get_media_timestamp_links, + can_get_message_thread, can_get_read_date, can_get_statistics, can_get_viewers, can_report_reactions, + can_recognize_speech)); } bool MessagesManager::is_message_edited_recently(MessageFullId message_full_id, int32 seconds) { @@ -25692,7 +25692,7 @@ void MessagesManager::edit_message_scheduling_state( if (!m->message_id.is_scheduled()) { return promise.set_error(Status::Error(400, "Message is not scheduled")); } - if (!m->message_id.is_scheduled_server()) { + if (!m->message_id.is_valid_scheduled() || !m->message_id.is_scheduled_server()) { return promise.set_error(Status::Error(400, "Can't reschedule the message")); }