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

View File

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