Add td_api::userPrivacySettingRuleAllowPremiumUsers.

This commit is contained in:
levlam 2024-03-21 14:31:41 +03:00
parent f361989c05
commit ee2bdcfd1d
3 changed files with 17 additions and 6 deletions

View File

@ -5528,6 +5528,9 @@ userPrivacySettingRuleAllowAll = UserPrivacySettingRule;
//@description A rule to allow all contacts of the user to do something //@description A rule to allow all contacts of the user to do something
userPrivacySettingRuleAllowContacts = UserPrivacySettingRule; userPrivacySettingRuleAllowContacts = UserPrivacySettingRule;
//@description A rule to allow all Premium Users to do something; currently, allowed only for userPrivacySettingAllowChatInvites
userPrivacySettingRuleAllowPremiumUsers = UserPrivacySettingRule;
//@description A rule to allow certain specified users to do something @user_ids The user identifiers, total number of users in all rules must not exceed 1000 //@description A rule to allow certain specified users to do something @user_ids The user identifiers, total number of users in all rules must not exceed 1000
userPrivacySettingRuleAllowUsers user_ids:vector<int53> = UserPrivacySettingRule; userPrivacySettingRuleAllowUsers user_ids:vector<int53> = UserPrivacySettingRule;

View File

@ -53,6 +53,9 @@ UserPrivacySettingRule::UserPrivacySettingRule(Td *td, const td_api::UserPrivacy
case td_api::userPrivacySettingRuleAllowContacts::ID: case td_api::userPrivacySettingRuleAllowContacts::ID:
type_ = Type::AllowContacts; type_ = Type::AllowContacts;
break; break;
case td_api::userPrivacySettingRuleAllowPremiumUsers::ID:
type_ = Type::AllowPremium;
break;
case td_api::userPrivacySettingRuleAllowAll::ID: case td_api::userPrivacySettingRuleAllowAll::ID:
type_ = Type::AllowAll; type_ = Type::AllowAll;
break; break;
@ -91,6 +94,9 @@ UserPrivacySettingRule::UserPrivacySettingRule(Td *td,
case telegram_api::privacyValueAllowContacts::ID: case telegram_api::privacyValueAllowContacts::ID:
type_ = Type::AllowContacts; type_ = Type::AllowContacts;
break; break;
case telegram_api::privacyValueAllowPremium::ID:
type_ = Type::AllowPremium;
break;
case telegram_api::privacyValueAllowCloseFriends::ID: case telegram_api::privacyValueAllowCloseFriends::ID:
type_ = Type::AllowCloseFriends; type_ = Type::AllowCloseFriends;
break; break;
@ -121,9 +127,6 @@ UserPrivacySettingRule::UserPrivacySettingRule(Td *td,
set_dialog_ids_from_server(td, set_dialog_ids_from_server(td,
static_cast<const telegram_api::privacyValueDisallowChatParticipants &>(*rule).chats_); static_cast<const telegram_api::privacyValueDisallowChatParticipants &>(*rule).chats_);
break; break;
case telegram_api::privacyValueAllowPremium::ID:
type_ = Type::AllowContacts;
break;
default: default:
UNREACHABLE(); UNREACHABLE();
} }
@ -159,6 +162,8 @@ td_api::object_ptr<td_api::UserPrivacySettingRule> UserPrivacySettingRule::get_u
switch (type_) { switch (type_) {
case Type::AllowContacts: case Type::AllowContacts:
return make_tl_object<td_api::userPrivacySettingRuleAllowContacts>(); return make_tl_object<td_api::userPrivacySettingRuleAllowContacts>();
case Type::AllowPremium:
return make_tl_object<td_api::userPrivacySettingRuleAllowPremiumUsers>();
case Type::AllowCloseFriends: case Type::AllowCloseFriends:
LOG(ERROR) << "Have AllowCloseFriends rule"; LOG(ERROR) << "Have AllowCloseFriends rule";
return make_tl_object<td_api::userPrivacySettingRuleAllowUsers>(); return make_tl_object<td_api::userPrivacySettingRuleAllowUsers>();
@ -190,6 +195,8 @@ telegram_api::object_ptr<telegram_api::InputPrivacyRule> UserPrivacySettingRule:
switch (type_) { switch (type_) {
case Type::AllowContacts: case Type::AllowContacts:
return make_tl_object<telegram_api::inputPrivacyValueAllowContacts>(); return make_tl_object<telegram_api::inputPrivacyValueAllowContacts>();
case Type::AllowPremium:
return make_tl_object<telegram_api::inputPrivacyValueAllowPremium>();
case Type::AllowCloseFriends: case Type::AllowCloseFriends:
return make_tl_object<telegram_api::inputPrivacyValueAllowCloseFriends>(); return make_tl_object<telegram_api::inputPrivacyValueAllowCloseFriends>();
case Type::AllowAll: case Type::AllowAll:

View File

@ -69,8 +69,8 @@ class UserPrivacySettingRule {
parser.set_error("Failed to parse chat identifiers"); parser.set_error("Failed to parse chat identifiers");
} }
} }
} else if (type_ != Type::AllowContacts && type_ != Type::AllowCloseFriends && type_ != Type::AllowAll && } else if (type_ != Type::AllowContacts && type_ != Type::AllowPremium && type_ != Type::AllowCloseFriends &&
type_ != Type::RestrictContacts && type_ != Type::RestrictAll) { type_ != Type::AllowAll && type_ != Type::RestrictContacts && type_ != Type::RestrictAll) {
parser.set_error("Invalid privacy rule type"); parser.set_error("Invalid privacy rule type");
} }
} }
@ -85,7 +85,8 @@ class UserPrivacySettingRule {
RestrictContacts, RestrictContacts,
RestrictAll, RestrictAll,
RestrictUsers, RestrictUsers,
RestrictChatParticipants RestrictChatParticipants,
AllowPremium
} type_ = Type::RestrictAll; } type_ = Type::RestrictAll;
friend class UserPrivacySettingRules; friend class UserPrivacySettingRules;