From 773f43d67be22ea89ebad608d1fc4e7bec3d937a Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 9 Jul 2024 13:50:37 +0300 Subject: [PATCH] Add separate messageProperties can_report_chat and can_report_supergroup_spam. --- td/generate/scheme/td_api.tl | 7 ++++--- td/telegram/MessagesManager.cpp | 18 ++++++++++++------ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index b26636c1c..88cde3f2e 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -3839,7 +3839,6 @@ inputMessageForwarded from_chat_id:int53 message_id:int53 in_game_share:Bool cop //@can_be_pinned True, if the message can be pinned or unpinned in the chat using pinChatMessage or unpinChatMessage //@can_be_replied True, if the message can be replied in the same chat and forum topic using inputMessageReplyToMessage //@can_be_replied_in_another_chat True, if the message can be replied in another chat or forum topic using inputMessageReplyToExternalMessage -//@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 @@ -3851,10 +3850,12 @@ inputMessageForwarded from_chat_id:int53 message_id:int53 in_game_share:Bool cop //@can_get_read_date True, if read date of the message can be received through getMessageReadDate //@can_get_statistics True, if the message statistics are available through getMessageStatistics and message forwards can be received using getMessagePublicForwards //@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 +//@can_report_chat True, if the message can be reported using reportChat +//@can_report_reactions True, if reactions on the message can be reported through reportMessageReactions +//@can_report_supergroup_spam True, if the message can be reported using reportSupergroupSpam //@can_set_fact_check True, if fact check for the message can be changed through setMessageFactCheck -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_pinned: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 can_set_fact_check: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_pinned:Bool can_be_replied:Bool can_be_replied_in_another_chat: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_recognize_speech:Bool can_report_chat:Bool can_report_reactions:Bool can_report_supergroup_spam:Bool can_set_fact_check:Bool = MessageProperties; //@class SearchMessagesFilter @description Represents a filter for message search results diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 5ca142000..9599f90e4 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -17353,7 +17353,6 @@ void MessagesManager::get_message_properties(DialogId dialog_id, MessageId messa !m->message_id.is_yet_unsent() && (!m->message_id.is_local() || dialog_type == DialogType::SecretChat) && (dialog_type != DialogType::Chat || td_->chat_manager_->get_chat_is_active(dialog_id.get_chat_id())); 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_; @@ -17364,15 +17363,22 @@ void MessagesManager::get_message_properties(DialogId dialog_id, MessageId messa auto can_get_media_timestamp_links = can_get_media_timestamp_link(dialog_id, m).is_ok(); auto can_get_link = can_get_media_timestamp_links && dialog_type == DialogType::Channel; auto can_get_embedding_code = can_get_message_embedding_code(dialog_id, m).is_ok(); - auto can_report_reactions = can_report_message_reactions(dialog_id, m); auto can_recognize_speech = can_recognize_message_speech(dialog_id, m); + auto can_report_chat = + td_->dialog_manager_->can_report_dialog(dialog_id) && can_report_message(m->message_id).is_ok(); + auto can_report_reactions = can_report_message_reactions(dialog_id, m); + auto can_report_supergroup_spam = + dialog_id.get_type() == DialogType::Channel && + td_->chat_manager_->is_megagroup_channel(dialog_id.get_channel_id()) && + td_->chat_manager_->get_channel_status(dialog_id.get_channel_id()).is_administrator() && + can_report_message(m->message_id).is_ok(); auto can_set_fact_check = can_set_message_fact_check(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_pinned, - can_be_replied, 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, can_set_fact_check)); + can_be_replied, can_be_replied_in_another_chat, 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_recognize_speech, + can_report_chat, can_report_reactions, can_report_supergroup_spam, can_set_fact_check)); } bool MessagesManager::is_message_edited_recently(MessageFullId message_full_id, int32 seconds) {