From 252ca3135cce1d99eab5a593ce375592bde47b26 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 9 Jan 2024 17:11:22 +0300 Subject: [PATCH] Add td_api::getReadDatePrivacySettings. --- td/generate/scheme/td_api.tl | 8 ++++++++ td/telegram/GlobalPrivacySettings.cpp | 6 ++++++ td/telegram/GlobalPrivacySettings.h | 2 ++ td/telegram/Td.cpp | 14 ++++++++++++++ td/telegram/Td.h | 2 ++ td/telegram/cli.cpp | 2 ++ 6 files changed, 34 insertions(+) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index d5e97b4a1..704b1783b 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -5393,6 +5393,11 @@ userPrivacySettingAllowFindingByPhoneNumber = UserPrivacySetting; userPrivacySettingAllowPrivateVoiceAndVideoNoteMessages = UserPrivacySetting; +//@description Contains privacy settings for message read date +//@show_read_date True, if message read date is shown to other users in private chats. If disabled and the current user isn't a Telegram Premium user, then they will not be able to see other's message read date +readDatePrivacySettings show_read_date:Bool = ReadDatePrivacySettings; + + //@description Contains information about the period of inactivity after which the current user's account will automatically be deleted @days Number of days of inactivity before the account will be flagged for deletion; 30-366 days accountTtl days:int32 = AccountTtl; @@ -9502,6 +9507,9 @@ setUserPrivacySettingRules setting:UserPrivacySetting rules:userPrivacySettingRu //@description Returns the current privacy settings @setting The privacy setting getUserPrivacySettingRules setting:UserPrivacySetting = UserPrivacySettingRules; +//@description Returns privacy settings for message read date +getReadDatePrivacySettings = ReadDatePrivacySettings; + //@description Returns the value of an option by its name. (Check the list of available options on https://core.telegram.org/tdlib/options.) Can be called before authorization. Can be called synchronously for options "version" and "commit_hash" //@name The name of the option diff --git a/td/telegram/GlobalPrivacySettings.cpp b/td/telegram/GlobalPrivacySettings.cpp index 7213696bd..952d7bf4b 100644 --- a/td/telegram/GlobalPrivacySettings.cpp +++ b/td/telegram/GlobalPrivacySettings.cpp @@ -132,6 +132,12 @@ td_api::object_ptr GlobalPrivacySettings::get_a keep_archived_unmuted_, keep_archived_folders_); } +td_api::object_ptr GlobalPrivacySettings::get_read_date_privacy_settings_object() + const { + CHECK(set_type_ == SetType::None); + return td_api::make_object(!hide_read_marks_); +} + void GlobalPrivacySettings::get_global_privacy_settings(Td *td, Promise &&promise) { td->create_handler(std::move(promise))->send(); } diff --git a/td/telegram/GlobalPrivacySettings.h b/td/telegram/GlobalPrivacySettings.h index faba02b8e..8721c4a21 100644 --- a/td/telegram/GlobalPrivacySettings.h +++ b/td/telegram/GlobalPrivacySettings.h @@ -36,6 +36,8 @@ class GlobalPrivacySettings { td_api::object_ptr get_archive_chat_list_settings_object() const; + td_api::object_ptr get_read_date_privacy_settings_object() const; + static void get_global_privacy_settings(Td *td, Promise &&promise); static void set_global_privacy_settings(Td *td, GlobalPrivacySettings settings, Promise &&promise); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 5201d0bd2..dae8936ee 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -6486,6 +6486,20 @@ void Td::on_request(uint64 id, td_api::setArchiveChatListSettings &request) { std::move(promise)); } +void Td::on_request(uint64 id, const td_api::getReadDatePrivacySettings &request) { + CHECK_IS_USER(); + CREATE_REQUEST_PROMISE(); + auto query_promise = + PromiseCreator::lambda([promise = std::move(promise)](Result result) mutable { + if (result.is_error()) { + promise.set_error(result.move_as_error()); + } else { + promise.set_value(result.ok().get_read_date_privacy_settings_object()); + } + }); + GlobalPrivacySettings::get_global_privacy_settings(this, std::move(query_promise)); +} + void Td::on_request(uint64 id, td_api::setChatTitle &request) { CLEAN_INPUT_STRING(request.title_); CREATE_OK_REQUEST_PROMISE(); diff --git a/td/telegram/Td.h b/td/telegram/Td.h index 5f7a098ce..bd7a4d35e 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -1051,6 +1051,8 @@ class Td final : public Actor { void on_request(uint64 id, td_api::setArchiveChatListSettings &request); + void on_request(uint64 id, const td_api::getReadDatePrivacySettings &request); + void on_request(uint64 id, td_api::setChatTitle &request); void on_request(uint64 id, const td_api::setChatPhoto &request); diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 6ad363e0c..01ead2971 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -5435,6 +5435,8 @@ class CliClient final : public Actor { auto settings = td_api::make_object( archive_and_mute_new_chats_from_unknown_users, keep_unmuted_chats_archived, keep_chats_from_folders_archived); send_request(td_api::make_object(std::move(settings))); + } else if (op == "grdps") { + send_request(td_api::make_object()); } else if (op == "sct") { ChatId chat_id; string title;