Rename allow_saving_content to has_private_content.

This commit is contained in:
levlam 2021-12-06 21:43:55 +03:00
parent ecc8889cac
commit 831ca4b975
9 changed files with 49 additions and 49 deletions

View File

@ -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<chatPosition> 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<chatPosition> 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<int53> = 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;

View File

@ -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;

View File

@ -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);

View File

@ -331,7 +331,7 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
}
case telegram_api::channelAdminLogEventActionToggleNoForwards::ID: {
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionToggleNoForwards>(action_ptr);
return td_api::make_object<td_api::chatEventAllowSavingContentToggled>(!action->new_value_);
return td_api::make_object<td_api::chatEventHasProtectedContentToggled>(action->new_value_);
}
default:
UNREACHABLE();

View File

@ -1485,12 +1485,12 @@ class ToggleNoForwardsQuery final : public Td::ResultHandler {
explicit ToggleNoForwardsQuery(Promise<Unit> &&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<td_api::chat> 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::ForwardedMessages> 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 &copy_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<td_api::updateChatAllowSavingContent>(dialog_id.get(),
get_dialog_allow_saving_content(dialog_id)));
td_api::make_object<td_api::updateChatHasProtectedContent>(
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<EditChatDefaultBannedRightsQuery>(std::move(promise))->send(dialog_id, new_permissions);
}
void MessagesManager::toggle_dialog_allow_saving_content(DialogId dialog_id, bool allow_saving_content,
void MessagesManager::toggle_dialog_has_protected_content(DialogId dialog_id, bool has_protected_content,
Promise<Unit> &&promise) {
if (!have_dialog_force(dialog_id, "toggle_dialog_allow_saving_content")) {
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<ToggleNoForwardsQuery>(std::move(promise))->send(dialog_id, allow_saving_content);
td_->create_handler<ToggleNoForwardsQuery>(std::move(promise))->send(dialog_id, has_protected_content);
}
void MessagesManager::set_dialog_theme(DialogId dialog_id, const string &theme_name, Promise<Unit> &&promise) {

View File

@ -506,7 +506,7 @@ class MessagesManager final : public Actor {
void set_dialog_permissions(DialogId dialog_id, const td_api::object_ptr<td_api::chatPermissions> &permissions,
Promise<Unit> &&promise);
void toggle_dialog_allow_saving_content(DialogId dialog_id, bool allow_saving_content, Promise<Unit> &&promise);
void toggle_dialog_has_protected_content(DialogId dialog_id, bool has_protected_content, Promise<Unit> &&promise);
void set_dialog_theme(DialogId dialog_id, const string &theme_name, Promise<Unit> &&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;

View File

@ -6157,10 +6157,10 @@ 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_,
messages_manager_->toggle_dialog_has_protected_content(DialogId(request.chat_id_), request.has_protected_content_,
std::move(promise));
}

View File

@ -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);

View File

@ -3194,10 +3194,10 @@ class CliClient final : public Actor {
send_request(td_api::make_object<td_api::clearAllDraftMessages>());
} 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<td_api::toggleChatAllowSavingContent>(as_chat_id(chat_id), allow_saving_content));
td_api::make_object<td_api::toggleChatHasProtectedContent>(as_chat_id(chat_id), has_protected_content));
} else if (op == "tcip" || op == "tcipa" || begins_with(op, "tcip-")) {
string chat_id;
bool is_pinned;