Add td_api::setReadDatePrivacySettings.

This commit is contained in:
levlam 2024-01-09 17:56:47 +03:00
parent 252ca3135c
commit 2504de4978
6 changed files with 30 additions and 1 deletions

View File

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

View File

@ -88,6 +88,13 @@ GlobalPrivacySettings::GlobalPrivacySettings(td_api::object_ptr<td_api::archiveC
}
}
GlobalPrivacySettings::GlobalPrivacySettings(td_api::object_ptr<td_api::readDatePrivacySettings> &&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;

View File

@ -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<td_api::archiveChatListSettings> &&settings);
explicit GlobalPrivacySettings(td_api::object_ptr<td_api::readDatePrivacySettings> &&settings);
telegram_api::object_ptr<telegram_api::globalPrivacySettings> get_input_global_privacy_settings() const;
td_api::object_ptr<td_api::archiveChatListSettings> get_archive_chat_list_settings_object() const;

View File

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

View File

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

View File

@ -5437,6 +5437,11 @@ class CliClient final : public Actor {
send_request(td_api::make_object<td_api::setArchiveChatListSettings>(std::move(settings)));
} else if (op == "grdps") {
send_request(td_api::make_object<td_api::getReadDatePrivacySettings>());
} else if (op == "srdps") {
bool show_read_date;
get_args(args, show_read_date);
auto settings = td_api::make_object<td_api::readDatePrivacySettings>(show_read_date);
send_request(td_api::make_object<td_api::setReadDatePrivacySettings>(std::move(settings)));
} else if (op == "sct") {
ChatId chat_id;
string title;