Add chat.an_be_deleted_*.

GitOrigin-RevId: af1c5ff5c3cec46c25973dc644df777544906af5
This commit is contained in:
levlam 2019-04-15 05:48:42 +03:00
parent aa96b03908
commit 79cc50ed41
3 changed files with 43 additions and 4 deletions

View File

@ -589,6 +589,8 @@ chatTypeSecret secret_chat_id:int32 user_id:int32 = ChatType;
//@is_pinned True, if the chat is pinned //@is_pinned True, if the chat is pinned
//@is_marked_as_unread True, if the chat is marked as unread //@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 //@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 //@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 //@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 //@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 //@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 //@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 //@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 //@description Represents a list of chats @chat_ids List of chat identifiers
chats chat_ids:vector<int53> = Chats; chats chat_ids:vector<int53> = Chats;

Binary file not shown.

View File

@ -13304,14 +13304,51 @@ tl_object_ptr<td_api::ChatType> MessagesManager::get_chat_type_object(DialogId d
tl_object_ptr<td_api::chat> MessagesManager::get_chat_object(const Dialog *d) const { tl_object_ptr<td_api::chat> MessagesManager::get_chat_object(const Dialog *d) const {
CHECK(d != nullptr); 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<td_api::chat>( return make_tl_object<td_api::chat>(
d->dialog_id.get(), get_chat_type_object(d->dialog_id), get_dialog_title(d->dialog_id), 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_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)), 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, 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->is_marked_as_unread, d->order == SPONSORED_DIALOG_ORDER, can_delete_for_self, can_delete_for_all_users,
d->notification_settings.silent_send_message, d->server_unread_count + d->local_unread_count, can_report_dialog(d->dialog_id), d->notification_settings.silent_send_message,
d->last_read_inbox_message_id.get(), d->last_read_outbox_message_id.get(), d->unread_mention_count, 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(), 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); d->reply_markup_message_id.get(), get_draft_message_object(d->draft_message), d->client_data);
} }