From 79cc50ed418dcca77c81e734312ebc4709aef219 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 15 Apr 2019 05:48:42 +0300 Subject: [PATCH] Add chat.an_be_deleted_*. GitOrigin-RevId: af1c5ff5c3cec46c25973dc644df777544906af5 --- td/generate/scheme/td_api.tl | 4 ++- td/generate/scheme/td_api.tlo | Bin 150900 -> 151012 bytes td/telegram/MessagesManager.cpp | 43 +++++++++++++++++++++++++++++--- 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index b0e618d6..2d05c3ce 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -589,6 +589,8 @@ chatTypeSecret secret_chat_id:int32 user_id:int32 = ChatType; //@is_pinned True, if the chat is pinned //@is_marked_as_unread True, if the chat is marked as unread //@is_sponsored True, if the chat is sponsored by the user's MTProxy server +//@can_be_deleted_only_for_self True, if the chat messages can be deleted only for the current user while other users will continue to see the messages +//@can_be_deleted_for_all_users True, if the chat messages can be deleted for all users //@can_be_reported True, if the chat can be reported to Telegram moderators through reportChat //@default_disable_notification Default value of the disable_notification parameter, used when a message is sent to the chat //@unread_count Number of unread messages in the chat @@ -600,7 +602,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 is_marked_as_unread:Bool is_sponsored:Bool can_be_reported:Bool default_disable_notification:Bool unread_count:int32 last_read_inbox_message_id:int53 last_read_outbox_message_id:int53 unread_mention_count:int32 notification_settings:chatNotificationSettings pinned_message_id:int53 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 is_marked_as_unread:Bool is_sponsored:Bool can_be_deleted_only_for_self:Bool can_be_deleted_for_all_users:Bool can_be_reported:Bool default_disable_notification:Bool unread_count:int32 last_read_inbox_message_id:int53 last_read_outbox_message_id:int53 unread_mention_count:int32 notification_settings:chatNotificationSettings pinned_message_id:int53 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 af630b33d1890d0d1cf8c382250761ef222fd131..9b32c2a29cfaed1b9e8abb6adbff15671c9bb3d1 100644 GIT binary patch delta 351 zcmew|i}T5B&J9$89C$`~ z^B!9T#>p{f3pd}j`_0G#l54)>u>Fn$;{rV}Z+k;N(Qg z3&5<&bE;jY#~gx*x4>A_n3xP8hCDdLsK5wz7|3Sk$%$I((+!R=`ale7I0DnUp^i}p z$%a1&i35xl5XA{c88sj*0}m!7=WKs*l+i;1A~RtFBh=!IdyE&<59S_AQLs=lP>6wn0mQy}Ovp!M^1(C8 zoA=l%FmCp-|HH@v5^wf#-0tJZxIhog+x{V+aY`VVIekteqserGV~i>g?vsOz3&5<& zJT)%U&m4k@e}S_Kn3xP8rUV>jRA2q# zaEXJA77)c3jxuUMSPMLukleF9;uxcc1XyO;Mn MessagesManager::get_chat_type_object(DialogId d tl_object_ptr MessagesManager::get_chat_object(const Dialog *d) const { CHECK(d != nullptr); + + bool can_delete_for_self = false; + bool can_delete_for_all_users = false; + if (!td_->auth_manager_->is_bot()) { + switch (d->dialog_id.get_type()) { + case DialogType::User: + can_delete_for_self = true; + can_delete_for_all_users = G()->shared_config().get_option_boolean("revoke_pm_inbox", true); + if (d->dialog_id == get_my_dialog_id() || td_->contacts_manager_->is_user_deleted(d->dialog_id.get_user_id()) || + td_->contacts_manager_->is_user_bot(d->dialog_id.get_user_id())) { + can_delete_for_all_users = false; + } + break; + case DialogType::Chat: + // chats can't be deleted only for self with deleteChatHistory + can_delete_for_self = true; + break; + case DialogType::Channel: + if (is_broadcast_channel(d->dialog_id) || + !td_->contacts_manager_->get_channel_username(d->dialog_id.get_channel_id()).empty()) { + // deleteChatHistory can't be used in channels and public supergroups + } else { + // private supergroups can be deleted for self + can_delete_for_self = true; + } + break; + case DialogType::SecretChat: + // secret chats can be deleted only for both users + can_delete_for_all_users = true; + break; + case DialogType::None: + default: + UNREACHABLE(); + } + } + return make_tl_object( d->dialog_id.get(), get_chat_type_object(d->dialog_id), get_dialog_title(d->dialog_id), 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->is_marked_as_unread, d->order == SPONSORED_DIALOG_ORDER, can_report_dialog(d->dialog_id), - d->notification_settings.silent_send_message, 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, + d->is_marked_as_unread, d->order == SPONSORED_DIALOG_ORDER, can_delete_for_self, can_delete_for_all_users, + can_report_dialog(d->dialog_id), d->notification_settings.silent_send_message, + 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_chat_notification_settings_object(&d->notification_settings), d->pinned_message_id.get(), d->reply_markup_message_id.get(), get_draft_message_object(d->draft_message), d->client_data); }