diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 704b1783b..7cb219d38 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -9507,6 +9507,9 @@ setUserPrivacySettingRules setting:UserPrivacySetting rules:userPrivacySettingRu //@description Returns the current privacy settings @setting The privacy setting getUserPrivacySettingRules setting:UserPrivacySetting = UserPrivacySettingRules; +//@description Changes privacy settings for message read date @settings New settings +setReadDatePrivacySettings settings:readDatePrivacySettings = Ok; + //@description Returns privacy settings for message read date getReadDatePrivacySettings = ReadDatePrivacySettings; diff --git a/td/telegram/GlobalPrivacySettings.cpp b/td/telegram/GlobalPrivacySettings.cpp index 952d7bf4b..cc3b0e665 100644 --- a/td/telegram/GlobalPrivacySettings.cpp +++ b/td/telegram/GlobalPrivacySettings.cpp @@ -88,6 +88,13 @@ GlobalPrivacySettings::GlobalPrivacySettings(td_api::object_ptr &&settings) + : set_type_(SetType::ReadDate) { + if (settings != nullptr) { + hide_read_marks_ = !settings->show_read_date_; + } +} + void GlobalPrivacySettings::apply_changes(const GlobalPrivacySettings &set_settings) { CHECK(set_type_ == SetType::None); switch (set_settings.set_type_) { @@ -96,6 +103,9 @@ void GlobalPrivacySettings::apply_changes(const GlobalPrivacySettings &set_setti keep_archived_unmuted_ = set_settings.keep_archived_unmuted_; keep_archived_folders_ = set_settings.keep_archived_folders_; break; + case SetType::ReadDate: + hide_read_marks_ = set_settings.hide_read_marks_; + break; default: UNREACHABLE(); break; diff --git a/td/telegram/GlobalPrivacySettings.h b/td/telegram/GlobalPrivacySettings.h index 8721c4a21..7918e798b 100644 --- a/td/telegram/GlobalPrivacySettings.h +++ b/td/telegram/GlobalPrivacySettings.h @@ -17,7 +17,7 @@ namespace td { class Td; class GlobalPrivacySettings { - enum class SetType : int32 { None, Archive }; + enum class SetType : int32 { None, Archive, ReadDate }; SetType set_type_ = SetType::None; bool archive_and_mute_new_noncontact_peers_ = false; bool keep_archived_unmuted_ = false; @@ -32,6 +32,8 @@ class GlobalPrivacySettings { explicit GlobalPrivacySettings(td_api::object_ptr &&settings); + explicit GlobalPrivacySettings(td_api::object_ptr &&settings); + telegram_api::object_ptr get_input_global_privacy_settings() const; td_api::object_ptr get_archive_chat_list_settings_object() const; diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index dae8936ee..196ec85c4 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -6500,6 +6500,13 @@ void Td::on_request(uint64 id, const td_api::getReadDatePrivacySettings &request GlobalPrivacySettings::get_global_privacy_settings(this, std::move(query_promise)); } +void Td::on_request(uint64 id, td_api::setReadDatePrivacySettings &request) { + CHECK_IS_USER(); + CREATE_OK_REQUEST_PROMISE(); + GlobalPrivacySettings::set_global_privacy_settings(this, GlobalPrivacySettings(std::move(request.settings_)), + std::move(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 bd7a4d35e..d7f246b08 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -1053,6 +1053,8 @@ class Td final : public Actor { void on_request(uint64 id, const td_api::getReadDatePrivacySettings &request); + void on_request(uint64 id, td_api::setReadDatePrivacySettings &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 01ead2971..e4ce0b076 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -5437,6 +5437,11 @@ class CliClient final : public Actor { send_request(td_api::make_object(std::move(settings))); } else if (op == "grdps") { send_request(td_api::make_object()); + } else if (op == "srdps") { + bool show_read_date; + get_args(args, show_read_date); + auto settings = td_api::make_object(show_read_date); + send_request(td_api::make_object(std::move(settings))); } else if (op == "sct") { ChatId chat_id; string title;