From 831ca4b97502f378dd6e040d8bbb6c8a57c9e192 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 6 Dec 2021 21:43:55 +0300 Subject: [PATCH] Rename allow_saving_content to has_private_content. --- td/generate/scheme/td_api.tl | 16 ++++++------- td/telegram/ContactsManager.cpp | 16 ++++++------- td/telegram/ContactsManager.h | 4 ++-- td/telegram/DialogEventLog.cpp | 2 +- td/telegram/MessagesManager.cpp | 40 ++++++++++++++++----------------- td/telegram/MessagesManager.h | 6 ++--- td/telegram/Td.cpp | 6 ++--- td/telegram/Td.h | 2 +- td/telegram/cli.cpp | 6 ++--- 9 files changed, 49 insertions(+), 49 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index ec7b3cccc..370e193cf 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -966,7 +966,7 @@ videoChat group_call_id:int32 has_participants:Bool default_participant_id:Messa //@last_message Last message in the chat; may be null //@positions Positions of the chat in chat lists //@default_message_sender_id Default identifier of a user or chat that is chosen to send messages in the chat; may be null if the user can't change message sender -//@allow_saving_content True, if chat content can be saved locally, forwarded, or copied +//@has_protected_content True, if chat content can't be saved locally, forwarded, or copied //@is_marked_as_unread True, if the chat is marked as unread //@is_blocked True, if the chat is blocked by the current user and private messages from the chat can't be received //@has_scheduled_messages True, if the chat has scheduled messages @@ -987,7 +987,7 @@ videoChat group_call_id:int32 has_participants:Bool default_participant_id:Messa //@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 Application-specific data associated with the chat. (For example, the chat scroll position or local chat notification settings can be stored here.) Persistent if the message database is used -chat id:int53 type:ChatType title:string photo:chatPhotoInfo permissions:chatPermissions last_message:message positions:vector default_message_sender_id:MessageSender allow_saving_content:Bool is_marked_as_unread:Bool is_blocked:Bool has_scheduled_messages: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 message_ttl_setting:int32 theme_name:string action_bar:ChatActionBar video_chat:videoChat pending_join_requests:chatJoinRequestsInfo reply_markup_message_id:int53 draft_message:draftMessage client_data:string = Chat; +chat id:int53 type:ChatType title:string photo:chatPhotoInfo permissions:chatPermissions last_message:message positions:vector default_message_sender_id:MessageSender has_protected_content:Bool is_marked_as_unread:Bool is_blocked:Bool has_scheduled_messages: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 message_ttl_setting:int32 theme_name:string action_bar:ChatActionBar video_chat:videoChat pending_join_requests:chatJoinRequestsInfo reply_markup_message_id:int53 draft_message:draftMessage client_data:string = Chat; //@description Represents a list of chats @total_count Approximate total count of chats found @chat_ids List of chat identifiers chats total_count:int32 chat_ids:vector = Chats; @@ -2603,8 +2603,8 @@ chatEventMessageTtlSettingChanged old_message_ttl_setting:int32 new_message_ttl_ //@description The sign_messages setting of a channel was toggled @sign_messages New value of sign_messages chatEventSignMessagesToggled sign_messages:Bool = ChatEventAction; -//@description The allow_saving_content setting of a channel was toggled @allow_saving_content New value of allow_saving_content -chatEventAllowSavingContentToggled allow_saving_content:Bool = ChatEventAction; +//@description The has_protected_content setting of a channel was toggled @has_protected_content New value of has_protected_content +chatEventHasProtectedContentToggled has_protected_content:Bool = ChatEventAction; //@description The supergroup sticker set was changed @old_sticker_set_id Previous identifier of the chat sticker set; 0 if none @new_sticker_set_id New identifier of the chat sticker set; 0 if none chatEventStickerSetChanged old_sticker_set_id:int64 new_sticker_set_id:int64 = ChatEventAction; @@ -3731,8 +3731,8 @@ updateChatPosition chat_id:int53 position:chatPosition = Update; //@description The default message sender that is chosen to send messages in a chat has changed @chat_id Chat identifier @default_message_sender_id New value of default_message_sender_id; may be null if the user can't change message sender updateChatDefaultMessageSenderId chat_id:int53 default_message_sender_id:MessageSender = Update; -//@description A chat content was allowed or restricted for saving @chat_id Chat identifier @allow_saving_content New value of allow_saving_content -updateChatAllowSavingContent chat_id:int53 allow_saving_content:Bool = Update; +//@description A chat content was allowed or restricted for saving @chat_id Chat identifier @has_protected_content New value of has_protected_content +updateChatHasProtectedContent chat_id:int53 has_protected_content:Bool = Update; //@description A chat was marked as unread or was read @chat_id Chat identifier @is_marked_as_unread New value of is_marked_as_unread updateChatIsMarkedAsUnread chat_id:int53 is_marked_as_unread:Bool = Update; @@ -4790,8 +4790,8 @@ setChatDraftMessage chat_id:int53 message_thread_id:int53 draft_message:draftMes setChatNotificationSettings chat_id:int53 notification_settings:chatNotificationSettings = Ok; //@description Changes the ability of users to save, forward, or copy chat content. Supported only for basic groups, supergroups and channels. Requires owner privileges -//@chat_id Chat identifier @allow_saving_content True, if chat content can be saved locally, forwarded, or copied -toggleChatAllowSavingContent chat_id:int53 allow_saving_content:Bool = Ok; +//@chat_id Chat identifier @has_protected_content True, if chat content can't be saved locally, forwarded, or copied +toggleChatHasProtectedContent chat_id:int53 has_protected_content:Bool = Ok; //@description Changes the marked as unread state of a chat @chat_id Chat identifier @is_marked_as_unread New value of is_marked_as_unread toggleChatIsMarkedAsUnread chat_id:int53 is_marked_as_unread:Bool = Ok; diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 72400a62e..cabf40a6c 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -4676,20 +4676,20 @@ RestrictedRights ContactsManager::get_secret_chat_default_permissions(SecretChat return RestrictedRights(true, true, true, true, true, true, true, true, false, false, false); } -bool ContactsManager::get_chat_allow_saving_content(ChatId chat_id) const { +bool ContactsManager::get_chat_has_protected_content(ChatId chat_id) const { auto c = get_chat(chat_id); if (c == nullptr) { return false; } - return !c->noforwards; + return c->noforwards; } -bool ContactsManager::get_channel_allow_saving_content(ChannelId channel_id) const { +bool ContactsManager::get_channel_has_protected_content(ChannelId channel_id) const { auto c = get_channel(channel_id); if (c == nullptr) { return false; } - return !c->noforwards; + return c->noforwards; } string ContactsManager::get_user_private_forward_name(UserId user_id) { @@ -9937,7 +9937,7 @@ void ContactsManager::update_chat(Chat *c, ChatId chat_id, bool from_binlog, boo c->is_status_changed = false; } if (c->is_noforwards_changed) { - td_->messages_manager_->on_dialog_allow_saving_content_updated(DialogId(chat_id)); + td_->messages_manager_->on_dialog_has_protected_content_updated(DialogId(chat_id)); c->is_noforwards_changed = false; } @@ -10031,7 +10031,7 @@ void ContactsManager::update_channel(Channel *c, ChannelId channel_id, bool from c->is_creator_changed = false; } if (c->is_noforwards_changed) { - td_->messages_manager_->on_dialog_allow_saving_content_updated(DialogId(channel_id)); + td_->messages_manager_->on_dialog_has_protected_content_updated(DialogId(channel_id)); c->is_noforwards_changed = false; } @@ -13085,7 +13085,7 @@ void ContactsManager::on_update_chat_default_permissions(Chat *c, ChatId chat_id void ContactsManager::on_update_chat_noforwards(Chat *c, ChatId chat_id, bool noforwards) { if (c->noforwards != noforwards) { - LOG(INFO) << "Update " << chat_id << " noforwards from " << c->noforwards << " to " << noforwards; + LOG(INFO) << "Update " << chat_id << " has_protected_content from " << c->noforwards << " to " << noforwards; c->noforwards = noforwards; c->is_noforwards_changed = true; c->need_save_to_database = true; @@ -13421,7 +13421,7 @@ void ContactsManager::on_update_channel_has_location(Channel *c, ChannelId chann void ContactsManager::on_update_channel_noforwards(Channel *c, ChannelId channel_id, bool noforwards) { if (c->noforwards != noforwards) { - LOG(INFO) << "Update " << channel_id << " noforwards from " << c->noforwards << " to " << noforwards; + LOG(INFO) << "Update " << channel_id << " has_protected_content from " << c->noforwards << " to " << noforwards; c->noforwards = noforwards; c->is_noforwards_changed = true; c->need_save_to_database = true; diff --git a/td/telegram/ContactsManager.h b/td/telegram/ContactsManager.h index 612590c36..996a7d69f 100644 --- a/td/telegram/ContactsManager.h +++ b/td/telegram/ContactsManager.h @@ -107,8 +107,8 @@ class ContactsManager final : public Actor { RestrictedRights get_channel_default_permissions(ChannelId channel_id) const; RestrictedRights get_secret_chat_default_permissions(SecretChatId secret_chat_id) const; - bool get_chat_allow_saving_content(ChatId chat_id) const; - bool get_channel_allow_saving_content(ChannelId channel_id) const; + bool get_chat_has_protected_content(ChatId chat_id) const; + bool get_channel_has_protected_content(ChannelId channel_id) const; string get_user_private_forward_name(UserId user_id); diff --git a/td/telegram/DialogEventLog.cpp b/td/telegram/DialogEventLog.cpp index 950f9c643..e6b96efd1 100644 --- a/td/telegram/DialogEventLog.cpp +++ b/td/telegram/DialogEventLog.cpp @@ -331,7 +331,7 @@ static td_api::object_ptr get_chat_event_action_object( } case telegram_api::channelAdminLogEventActionToggleNoForwards::ID: { auto action = move_tl_object_as(action_ptr); - return td_api::make_object(!action->new_value_); + return td_api::make_object(action->new_value_); } default: UNREACHABLE(); diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index c3d99e81b..312786122 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -1485,12 +1485,12 @@ class ToggleNoForwardsQuery final : public Td::ResultHandler { explicit ToggleNoForwardsQuery(Promise &&promise) : promise_(std::move(promise)) { } - void send(DialogId dialog_id, bool allow_saving_content) { + void send(DialogId dialog_id, bool has_protected_content) { dialog_id_ = dialog_id; auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); CHECK(input_peer != nullptr); send_query(G()->net_query_creator().create( - telegram_api::messages_toggleNoForwards(std::move(input_peer), !allow_saving_content))); + telegram_api::messages_toggleNoForwards(std::move(input_peer), has_protected_content))); } void on_result(BufferSlice packet) final { @@ -10184,7 +10184,7 @@ bool MessagesManager::can_save_message(DialogId dialog_id, const Message *m) con if (m == nullptr || m->noforwards || m->is_content_secret) { return false; } - return get_dialog_allow_saving_content(dialog_id); + return !get_dialog_has_protected_content(dialog_id); } bool MessagesManager::can_get_message_statistics(FullMessageId full_message_id) { @@ -20335,7 +20335,7 @@ td_api::object_ptr MessagesManager::get_chat_object(const Dialog * get_chat_photo_info_object(td_->file_manager_.get(), get_dialog_photo(d->dialog_id)), get_dialog_default_permissions(d->dialog_id).get_chat_permissions_object(), get_message_object(d->dialog_id, get_message(d, d->last_message_id), "get_chat_object"), - get_chat_positions_object(d), get_default_sender_id_object(d), get_dialog_allow_saving_content(d->dialog_id), + get_chat_positions_object(d), get_default_sender_id_object(d), get_dialog_has_protected_content(d->dialog_id), d->is_marked_as_unread, d->is_blocked, get_dialog_has_scheduled_messages(d), 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(), @@ -26953,7 +26953,7 @@ Result MessagesManager::get_forwarded_messag if (from_dialog_id.get_type() == DialogType::SecretChat) { return Status::Error(400, "Can't forward messages from secret chats"); } - if (!get_dialog_allow_saving_content(from_dialog_id)) { + if (get_dialog_has_protected_content(from_dialog_id)) { for (const auto ©_option : copy_options) { if (!copy_option.send_copy || !td_->auth_manager_->is_bot()) { return Status::Error(400, "Administrators of the chat restricted message forwarding"); @@ -31091,12 +31091,12 @@ void MessagesManager::on_dialog_default_permissions_updated(DialogId dialog_id) } } -void MessagesManager::on_dialog_allow_saving_content_updated(DialogId dialog_id) { +void MessagesManager::on_dialog_has_protected_content_updated(DialogId dialog_id) { auto d = get_dialog(dialog_id); // called from update_chat, must not create the dialog if (d != nullptr && d->is_update_new_chat_sent) { send_closure(G()->td(), &Td::send_update, - td_api::make_object(dialog_id.get(), - get_dialog_allow_saving_content(dialog_id))); + td_api::make_object( + dialog_id.get(), get_dialog_has_protected_content(dialog_id))); } } @@ -31550,20 +31550,20 @@ RestrictedRights MessagesManager::get_dialog_default_permissions(DialogId dialog } } -bool MessagesManager::get_dialog_allow_saving_content(DialogId dialog_id) const { +bool MessagesManager::get_dialog_has_protected_content(DialogId dialog_id) const { switch (dialog_id.get_type()) { case DialogType::User: - return true; + return false; case DialogType::Chat: - return td_->contacts_manager_->get_chat_allow_saving_content(dialog_id.get_chat_id()); + return td_->contacts_manager_->get_chat_has_protected_content(dialog_id.get_chat_id()); case DialogType::Channel: - return td_->contacts_manager_->get_channel_allow_saving_content(dialog_id.get_channel_id()); + return td_->contacts_manager_->get_channel_has_protected_content(dialog_id.get_channel_id()); case DialogType::SecretChat: - return true; + return false; case DialogType::None: default: UNREACHABLE(); - return false; + return true; } } @@ -32210,9 +32210,9 @@ void MessagesManager::set_dialog_permissions(DialogId dialog_id, td_->create_handler(std::move(promise))->send(dialog_id, new_permissions); } -void MessagesManager::toggle_dialog_allow_saving_content(DialogId dialog_id, bool allow_saving_content, - Promise &&promise) { - if (!have_dialog_force(dialog_id, "toggle_dialog_allow_saving_content")) { +void MessagesManager::toggle_dialog_has_protected_content(DialogId dialog_id, bool has_protected_content, + Promise &&promise) { + if (!have_dialog_force(dialog_id, "toggle_dialog_has_protected_content")) { return promise.set_error(Status::Error(400, "Chat not found")); } if (!have_input_peer(dialog_id, AccessRights::Read)) { @@ -32243,13 +32243,13 @@ void MessagesManager::toggle_dialog_allow_saving_content(DialogId dialog_id, boo UNREACHABLE(); } - // TODO this can be wrong if there were previous toggle_dialog_allow_saving_content requests - if (get_dialog_allow_saving_content(dialog_id) == allow_saving_content) { + // TODO this can be wrong if there were previous toggle_dialog_has_protected_content requests + if (get_dialog_has_protected_content(dialog_id) == has_protected_content) { return promise.set_value(Unit()); } // TODO invoke after - td_->create_handler(std::move(promise))->send(dialog_id, allow_saving_content); + td_->create_handler(std::move(promise))->send(dialog_id, has_protected_content); } void MessagesManager::set_dialog_theme(DialogId dialog_id, const string &theme_name, Promise &&promise) { diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 76eac2663..9772ad27d 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -506,7 +506,7 @@ class MessagesManager final : public Actor { void set_dialog_permissions(DialogId dialog_id, const td_api::object_ptr &permissions, Promise &&promise); - void toggle_dialog_allow_saving_content(DialogId dialog_id, bool allow_saving_content, Promise &&promise); + void toggle_dialog_has_protected_content(DialogId dialog_id, bool has_protected_content, Promise &&promise); void set_dialog_theme(DialogId dialog_id, const string &theme_name, Promise &&promise); @@ -802,7 +802,7 @@ class MessagesManager final : public Actor { void on_dialog_title_updated(DialogId dialog_id); void on_dialog_username_updated(DialogId dialog_id, const string &old_username, const string &new_username); void on_dialog_default_permissions_updated(DialogId dialog_id); - void on_dialog_allow_saving_content_updated(DialogId dialog_id); + void on_dialog_has_protected_content_updated(DialogId dialog_id); void on_dialog_user_is_contact_updated(DialogId dialog_id, bool is_contact); void on_dialog_user_is_deleted_updated(DialogId dialog_id, bool is_deleted); @@ -2900,7 +2900,7 @@ class MessagesManager final : public Actor { RestrictedRights get_dialog_default_permissions(DialogId dialog_id) const; - bool get_dialog_allow_saving_content(DialogId dialog_id) const; + bool get_dialog_has_protected_content(DialogId dialog_id) const; bool get_dialog_has_scheduled_messages(const Dialog *d) const; diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index fea3be69a..0cbcde9c0 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -6157,11 +6157,11 @@ void Td::on_request(uint64 id, td_api::setChatDraftMessage &request) { std::move(request.draft_message_))); } -void Td::on_request(uint64 id, const td_api::toggleChatAllowSavingContent &request) { +void Td::on_request(uint64 id, const td_api::toggleChatHasProtectedContent &request) { CHECK_IS_USER(); CREATE_OK_REQUEST_PROMISE(); - messages_manager_->toggle_dialog_allow_saving_content(DialogId(request.chat_id_), request.allow_saving_content_, - std::move(promise)); + messages_manager_->toggle_dialog_has_protected_content(DialogId(request.chat_id_), request.has_protected_content_, + std::move(promise)); } void Td::on_request(uint64 id, const td_api::toggleChatIsPinned &request) { diff --git a/td/telegram/Td.h b/td/telegram/Td.h index 916a2cc1c..fb030bc22 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -828,7 +828,7 @@ class Td final : public Actor { void on_request(uint64 id, td_api::setChatDraftMessage &request); - void on_request(uint64 id, const td_api::toggleChatAllowSavingContent &request); + void on_request(uint64 id, const td_api::toggleChatHasProtectedContent &request); void on_request(uint64 id, const td_api::toggleChatIsPinned &request); diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index ba4f7c59b..0c4053086 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -3194,10 +3194,10 @@ class CliClient final : public Actor { send_request(td_api::make_object()); } else if (op == "tcasc") { string chat_id; - bool allow_saving_content; - get_args(args, chat_id, allow_saving_content); + bool has_protected_content; + get_args(args, chat_id, has_protected_content); send_request( - td_api::make_object(as_chat_id(chat_id), allow_saving_content)); + td_api::make_object(as_chat_id(chat_id), has_protected_content)); } else if (op == "tcip" || op == "tcipa" || begins_with(op, "tcip-")) { string chat_id; bool is_pinned;