diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 8893471f..94edc60d 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -528,6 +528,7 @@ chatTypeSecret secret_chat_id:int32 user_id:int32 = ChatType; //@last_message Last message in the chat; may be null //@order Descending parameter by which chats are sorted in the main chat list. If the order number of two chats is the same, they must be sorted in descending order by ID. If 0, the position of the chat in the list is undetermined //@is_pinned True, if the chat is pinned +//#can_be_reported True, if the chat can be reported to Telegram moderators through reportChat //@unread_count Number of unread messages in the chat //@last_read_inbox_message_id Identifier of the last read incoming message //@last_read_outbox_message_id Identifier of the last read outgoing message @@ -536,7 +537,7 @@ chatTypeSecret secret_chat_id:int32 user_id:int32 = ChatType; //@reply_markup_message_id Identifier of the message from which reply markup needs to be used; 0 if there is no default custom reply markup in the chat //@draft_message A draft of a message in the chat; may be null //@client_data Contains client-specific data associated with the chat. (For example, the chat position or local chat notification settings can be stored here.) Persistent if a message database is used -chat id:int53 type:ChatType title:string photo:chatPhoto last_message:message order:int64 is_pinned:Bool unread_count:int32 last_read_inbox_message_id:int53 last_read_outbox_message_id:int53 unread_mention_count:int32 notification_settings:notificationSettings reply_markup_message_id:int53 draft_message:draftMessage client_data:string = Chat; +chat id:int53 type:ChatType title:string photo:chatPhoto last_message:message order:int64 is_pinned:Bool can_be_reported:Bool unread_count:int32 last_read_inbox_message_id:int53 last_read_outbox_message_id:int53 unread_mention_count:int32 notification_settings:notificationSettings reply_markup_message_id:int53 draft_message:draftMessage client_data:string = Chat; //@description Represents a list of chats @chat_ids List of chat identifiers chats chat_ids:vector = Chats; diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index fa28816c..148d437b 100644 Binary files a/td/generate/scheme/td_api.tlo and b/td/generate/scheme/td_api.tlo differ diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 057b26aa..f9ef6a47 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -6071,6 +6071,23 @@ void MessagesManager::change_dialog_report_spam_state(DialogId dialog_id, bool i } } +bool MessagesManager::can_report_dialog(DialogId dialog_id) const { + switch (dialog_id.get_type()) { + case DialogType::User: + return td_->contacts_manager_->is_user_bot(dialog_id.get_user_id()); + case DialogType::Chat: + return false; + case DialogType::Channel: + return !td_->contacts_manager_->get_channel_status(dialog_id.get_channel_id()).is_creator(); + case DialogType::SecretChat: + return false; + case DialogType::None: + default: + UNREACHABLE(); + return false; + } +} + void MessagesManager::report_dialog(DialogId dialog_id, const tl_object_ptr &reason, const vector &message_ids, Promise &&promise) { Dialog *d = get_dialog_force(dialog_id); @@ -6086,23 +6103,8 @@ void MessagesManager::report_dialog(DialogId dialog_id, const tl_object_ptrcontacts_manager_->is_user_bot(dialog_id.get_user_id())) { - // bots can be reported - break; - } - // fallthrough - case DialogType::Chat: - case DialogType::SecretChat: - return promise.set_error(Status::Error(3, "Chat can't be reported")); - case DialogType::None: - default: - UNREACHABLE(); - return; + if (!can_report_dialog(dialog_id)) { + return promise.set_error(Status::Error(3, "Chat can't be reported")); } vector server_message_ids; @@ -12375,8 +12377,8 @@ tl_object_ptr MessagesManager::get_chat_object(const Dialog *d) { get_chat_photo_object(td_->file_manager_.get(), get_dialog_photo(d->dialog_id)), get_message_object(d->dialog_id, get_message(d, d->last_message_id)), DialogDate(d->order, d->dialog_id) <= last_dialog_date_ ? d->order : 0, d->pinned_order != DEFAULT_ORDER, - d->server_unread_count + d->local_unread_count, d->last_read_inbox_message_id.get(), - d->last_read_outbox_message_id.get(), d->unread_mention_count, + can_report_dialog(d->dialog_id), d->server_unread_count + d->local_unread_count, + d->last_read_inbox_message_id.get(), d->last_read_outbox_message_id.get(), d->unread_mention_count, get_notification_settings_object(&d->notification_settings), d->reply_markup_message_id.get(), get_draft_message_object(d->draft_message), d->client_data); } diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 2dddbbb8..bc6c5b58 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -1824,6 +1824,8 @@ class MessagesManager : public Actor { bool can_edit_message(DialogId dialog_id, const Message *m, bool is_editing, bool only_reply_markup = false) const; + bool can_report_dialog(DialogId dialog_id) const; + MessageId get_persistent_message_id(const Dialog *d, MessageId message_id) const; static MessageId get_replied_message_id(const Message *m);