Add storyPrivacySettingsEveryone.except_user_ids.

This commit is contained in:
levlam 2023-08-02 13:50:44 +03:00
parent 63ba72dce4
commit bed1b43b85
3 changed files with 18 additions and 8 deletions

View File

@ -4497,16 +4497,16 @@ jsonValueObject members:vector<jsonObjectMember> = JsonValue;
//@class StoryPrivacySettings @description Describes privacy settings of a story //@class StoryPrivacySettings @description Describes privacy settings of a story
//@description The story can be viewed by everyone //@description The story can be viewed by everyone @except_user_ids Identifiers of the users that can't see the story; always unknown and empty for non-owned stories
storyPrivacySettingsEveryone = StoryPrivacySettings; storyPrivacySettingsEveryone except_user_ids:vector<int53> = StoryPrivacySettings;
//@description The story can be viewed by all contacts except chosen users @except_user_ids User identifiers of the contacts that can't see the story; always empty for non-owned stories //@description The story can be viewed by all contacts except chosen users @except_user_ids User identifiers of the contacts that can't see the story; always unknown and empty for non-owned stories
storyPrivacySettingsContacts except_user_ids:vector<int53> = StoryPrivacySettings; storyPrivacySettingsContacts except_user_ids:vector<int53> = StoryPrivacySettings;
//@description The story can be viewed by all close friends //@description The story can be viewed by all close friends
storyPrivacySettingsCloseFriends = StoryPrivacySettings; storyPrivacySettingsCloseFriends = StoryPrivacySettings;
//@description The story can be viewed by certain specified users @user_ids Identifiers of the users; always empty for non-owned stories //@description The story can be viewed by certain specified users @user_ids Identifiers of the users; always unknown and empty for non-owned stories
storyPrivacySettingsSelectedContacts user_ids:vector<int53> = StoryPrivacySettings; storyPrivacySettingsSelectedContacts user_ids:vector<int53> = StoryPrivacySettings;

View File

@ -295,9 +295,14 @@ Result<UserPrivacySettingRules> UserPrivacySettingRules::get_user_privacy_settin
} }
UserPrivacySettingRules result; UserPrivacySettingRules result;
switch (settings->get_id()) { switch (settings->get_id()) {
case td_api::storyPrivacySettingsEveryone::ID: case td_api::storyPrivacySettingsEveryone::ID: {
auto user_ids = std::move(static_cast<td_api::storyPrivacySettingsEveryone &>(*settings).except_user_ids_);
if (!user_ids.empty()) {
result.rules_.emplace_back(td, td_api::userPrivacySettingRuleRestrictUsers(std::move(user_ids)));
}
result.rules_.emplace_back(td, td_api::userPrivacySettingRuleAllowAll()); result.rules_.emplace_back(td, td_api::userPrivacySettingRuleAllowAll());
break; break;
}
case td_api::storyPrivacySettingsContacts::ID: { case td_api::storyPrivacySettingsContacts::ID: {
auto user_ids = std::move(static_cast<td_api::storyPrivacySettingsContacts &>(*settings).except_user_ids_); auto user_ids = std::move(static_cast<td_api::storyPrivacySettingsContacts &>(*settings).except_user_ids_);
if (!user_ids.empty()) { if (!user_ids.empty()) {
@ -337,6 +342,11 @@ td_api::object_ptr<td_api::StoryPrivacySettings> UserPrivacySettingRules::get_st
if (rules_.size() == 1u && rules_[0].type_ == UserPrivacySettingRule::Type::AllowAll) { if (rules_.size() == 1u && rules_[0].type_ == UserPrivacySettingRule::Type::AllowAll) {
return td_api::make_object<td_api::storyPrivacySettingsEveryone>(); return td_api::make_object<td_api::storyPrivacySettingsEveryone>();
} }
if (rules_.size() == 2u && rules_[0].type_ == UserPrivacySettingRule::Type::RestrictUsers &&
rules_[1].type_ == UserPrivacySettingRule::Type::AllowAll) {
return td_api::make_object<td_api::storyPrivacySettingsEveryone>(
td->contacts_manager_->get_user_ids_object(rules_[0].user_ids_, "storyPrivacySettingsEveryone"));
}
if (rules_.size() == 1u && rules_[0].type_ == UserPrivacySettingRule::Type::AllowContacts) { if (rules_.size() == 1u && rules_[0].type_ == UserPrivacySettingRule::Type::AllowContacts) {
return td_api::make_object<td_api::storyPrivacySettingsContacts>(); return td_api::make_object<td_api::storyPrivacySettingsContacts>();
} }

View File

@ -1177,14 +1177,14 @@ class CliClient final : public Actor {
string settings; string settings;
operator td_api::object_ptr<td_api::StoryPrivacySettings>() const { operator td_api::object_ptr<td_api::StoryPrivacySettings>() const {
if (settings == "a" || settings == "e") {
return td_api::make_object<td_api::storyPrivacySettingsEveryone>();
}
if (settings == "f" || settings == "cf") { if (settings == "f" || settings == "cf") {
return td_api::make_object<td_api::storyPrivacySettingsCloseFriends>(); return td_api::make_object<td_api::storyPrivacySettingsCloseFriends>();
} }
if (!settings.empty()) { if (!settings.empty()) {
auto user_ids = to_integers<int64>(Slice(settings).substr(1)); auto user_ids = to_integers<int64>(Slice(settings).substr(1));
if (settings[0] == 'a' || settings[0] == 'e') {
return td_api::make_object<td_api::storyPrivacySettingsEveryone>(std::move(user_ids));
}
if (settings[0] == 'c') { if (settings[0] == 'c') {
return td_api::make_object<td_api::storyPrivacySettingsContacts>(std::move(user_ids)); return td_api::make_object<td_api::storyPrivacySettingsContacts>(std::move(user_ids));
} }