Explicitly pass Td to UserPrivacySettingRule.

This commit is contained in:
levlam 2023-05-08 14:15:32 +03:00
parent 586586d50c
commit c4504af340
3 changed files with 79 additions and 72 deletions

View File

@ -169,7 +169,7 @@ void PrivacyManager::get_privacy(tl_object_ptr<td_api::UserPrivacySetting> key,
auto user_privacy_setting = r_user_privacy_setting.move_as_ok(); auto user_privacy_setting = r_user_privacy_setting.move_as_ok();
auto &info = get_info(user_privacy_setting); auto &info = get_info(user_privacy_setting);
if (info.is_synchronized) { if (info.is_synchronized) {
return promise.set_value(info.rules.get_user_privacy_setting_rules_object()); return promise.set_value(info.rules.get_user_privacy_setting_rules_object(G()->td().get_actor_unsafe()));
} }
info.get_promises.push_back(std::move(promise)); info.get_promises.push_back(std::move(promise));
if (info.get_promises.size() > 1u) { if (info.get_promises.size() > 1u) {
@ -185,7 +185,8 @@ void PrivacyManager::get_privacy(tl_object_ptr<td_api::UserPrivacySetting> key,
TRY_RESULT(net_query, std::move(x_net_query)); TRY_RESULT(net_query, std::move(x_net_query));
TRY_RESULT(rules, fetch_result<telegram_api::account_getPrivacy>(std::move(net_query))); TRY_RESULT(rules, fetch_result<telegram_api::account_getPrivacy>(std::move(net_query)));
LOG(INFO) << "Receive " << to_string(rules); LOG(INFO) << "Receive " << to_string(rules);
return UserPrivacySettingRules::get_user_privacy_setting_rules(std::move(rules)); return UserPrivacySettingRules::get_user_privacy_setting_rules(G()->td().get_actor_unsafe(),
std::move(rules));
}()); }());
})); }));
} }
@ -193,26 +194,30 @@ void PrivacyManager::get_privacy(tl_object_ptr<td_api::UserPrivacySetting> key,
void PrivacyManager::set_privacy(tl_object_ptr<td_api::UserPrivacySetting> key, void PrivacyManager::set_privacy(tl_object_ptr<td_api::UserPrivacySetting> key,
tl_object_ptr<td_api::userPrivacySettingRules> rules, Promise<Unit> promise) { tl_object_ptr<td_api::userPrivacySettingRules> rules, Promise<Unit> promise) {
TRY_RESULT_PROMISE(promise, user_privacy_setting, UserPrivacySetting::get_user_privacy_setting(std::move(key))); TRY_RESULT_PROMISE(promise, user_privacy_setting, UserPrivacySetting::get_user_privacy_setting(std::move(key)));
TRY_RESULT_PROMISE(promise, privacy_rules, UserPrivacySettingRules::get_user_privacy_setting_rules(std::move(rules))); TRY_RESULT_PROMISE(
promise, privacy_rules,
UserPrivacySettingRules::get_user_privacy_setting_rules(G()->td().get_actor_unsafe(), std::move(rules)));
auto &info = get_info(user_privacy_setting); auto &info = get_info(user_privacy_setting);
if (info.has_set_query) { if (info.has_set_query) {
// TODO cancel previous query // TODO cancel previous query
return promise.set_error(Status::Error(400, "Another set_privacy query is active")); return promise.set_error(Status::Error(400, "Another set_privacy query is active"));
} }
auto net_query = G()->net_query_creator().create(telegram_api::account_setPrivacy( auto net_query = G()->net_query_creator().create(
user_privacy_setting.get_input_privacy_key(), privacy_rules.get_input_privacy_rules())); telegram_api::account_setPrivacy(user_privacy_setting.get_input_privacy_key(),
privacy_rules.get_input_privacy_rules(G()->td().get_actor_unsafe())));
info.has_set_query = true; info.has_set_query = true;
send_with_promise( send_with_promise(std::move(net_query),
std::move(net_query), PromiseCreator::lambda([this, user_privacy_setting, promise = std::move(promise)]( PromiseCreator::lambda([this, user_privacy_setting,
Result<NetQueryPtr> x_net_query) mutable { promise = std::move(promise)](Result<NetQueryPtr> x_net_query) mutable {
promise.set_result([&]() -> Result<Unit> { promise.set_result([&]() -> Result<Unit> {
get_info(user_privacy_setting).has_set_query = false; get_info(user_privacy_setting).has_set_query = false;
TRY_RESULT(net_query, std::move(x_net_query)); TRY_RESULT(net_query, std::move(x_net_query));
TRY_RESULT(rules, fetch_result<telegram_api::account_setPrivacy>(std::move(net_query))); TRY_RESULT(rules, fetch_result<telegram_api::account_setPrivacy>(std::move(net_query)));
LOG(INFO) << "Receive " << to_string(rules); LOG(INFO) << "Receive " << to_string(rules);
TRY_RESULT(privacy_rules, UserPrivacySettingRules::get_user_privacy_setting_rules(std::move(rules))); TRY_RESULT(privacy_rules, UserPrivacySettingRules::get_user_privacy_setting_rules(
G()->td().get_actor_unsafe(), std::move(rules)));
do_update_privacy(user_privacy_setting, std::move(privacy_rules), true); do_update_privacy(user_privacy_setting, std::move(privacy_rules), true);
return Unit(); return Unit();
}()); }());
@ -223,7 +228,8 @@ void PrivacyManager::update_privacy(tl_object_ptr<telegram_api::updatePrivacy> u
CHECK(update != nullptr); CHECK(update != nullptr);
CHECK(update->key_ != nullptr); CHECK(update->key_ != nullptr);
UserPrivacySetting user_privacy_setting(*update->key_); UserPrivacySetting user_privacy_setting(*update->key_);
auto r_privacy_rules = UserPrivacySettingRules::get_user_privacy_setting_rules(std::move(update->rules_)); auto r_privacy_rules =
UserPrivacySettingRules::get_user_privacy_setting_rules(G()->td().get_actor_unsafe(), std::move(update->rules_));
if (r_privacy_rules.is_error()) { if (r_privacy_rules.is_error()) {
LOG(INFO) << "Skip updatePrivacy: " << r_privacy_rules.error().message(); LOG(INFO) << "Skip updatePrivacy: " << r_privacy_rules.error().message();
auto &info = get_info(user_privacy_setting); auto &info = get_info(user_privacy_setting);
@ -242,7 +248,7 @@ void PrivacyManager::on_get_result(UserPrivacySetting user_privacy_setting,
if (r_privacy_rules.is_error()) { if (r_privacy_rules.is_error()) {
promise.set_error(r_privacy_rules.error().clone()); promise.set_error(r_privacy_rules.error().clone());
} else { } else {
promise.set_value(r_privacy_rules.ok().get_user_privacy_setting_rules_object()); promise.set_value(r_privacy_rules.ok().get_user_privacy_setting_rules_object(G()->td().get_actor_unsafe()));
} }
} }
if (r_privacy_rules.is_ok()) { if (r_privacy_rules.is_ok()) {
@ -286,10 +292,10 @@ void PrivacyManager::do_update_privacy(UserPrivacySetting user_privacy_setting,
} }
info.rules = std::move(privacy_rules); info.rules = std::move(privacy_rules);
send_closure( send_closure(G()->td(), &Td::send_update,
G()->td(), &Td::send_update, make_tl_object<td_api::updateUserPrivacySettingRules>(
make_tl_object<td_api::updateUserPrivacySettingRules>(user_privacy_setting.get_user_privacy_setting_object(), user_privacy_setting.get_user_privacy_setting_object(),
info.rules.get_user_privacy_setting_rules_object())); info.rules.get_user_privacy_setting_rules_object(G()->td().get_actor_unsafe())));
} }
} }

View File

@ -10,7 +10,6 @@
#include "td/telegram/ChatId.h" #include "td/telegram/ChatId.h"
#include "td/telegram/ContactsManager.h" #include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogId.h" #include "td/telegram/DialogId.h"
#include "td/telegram/Global.h"
#include "td/telegram/MessagesManager.h" #include "td/telegram/MessagesManager.h"
#include "td/telegram/Td.h" #include "td/telegram/Td.h"
@ -21,9 +20,8 @@
namespace td { namespace td {
void UserPrivacySettingRule::set_chat_ids(const vector<int64> &dialog_ids) { void UserPrivacySettingRule::set_chat_ids(Td *td, const vector<int64> &dialog_ids) {
chat_ids_.clear(); chat_ids_.clear();
auto td = G()->td().get_actor_unsafe();
for (auto dialog_id_int : dialog_ids) { for (auto dialog_id_int : dialog_ids) {
DialogId dialog_id(dialog_id_int); DialogId dialog_id(dialog_id_int);
if (!td->messages_manager_->have_dialog_force(dialog_id, "UserPrivacySettingRule::set_chat_ids")) { if (!td->messages_manager_->have_dialog_force(dialog_id, "UserPrivacySettingRule::set_chat_ids")) {
@ -50,7 +48,7 @@ void UserPrivacySettingRule::set_chat_ids(const vector<int64> &dialog_ids) {
} }
} }
UserPrivacySettingRule::UserPrivacySettingRule(const td_api::UserPrivacySettingRule &rule) { UserPrivacySettingRule::UserPrivacySettingRule(Td *td, const td_api::UserPrivacySettingRule &rule) {
switch (rule.get_id()) { switch (rule.get_id()) {
case td_api::userPrivacySettingRuleAllowContacts::ID: case td_api::userPrivacySettingRuleAllowContacts::ID:
type_ = Type::AllowContacts; type_ = Type::AllowContacts;
@ -67,7 +65,7 @@ UserPrivacySettingRule::UserPrivacySettingRule(const td_api::UserPrivacySettingR
break; break;
case td_api::userPrivacySettingRuleAllowChatMembers::ID: case td_api::userPrivacySettingRuleAllowChatMembers::ID:
type_ = Type::AllowChatParticipants; type_ = Type::AllowChatParticipants;
set_chat_ids(static_cast<const td_api::userPrivacySettingRuleAllowChatMembers &>(rule).chat_ids_); set_chat_ids(td, static_cast<const td_api::userPrivacySettingRuleAllowChatMembers &>(rule).chat_ids_);
break; break;
case td_api::userPrivacySettingRuleRestrictContacts::ID: case td_api::userPrivacySettingRuleRestrictContacts::ID:
type_ = Type::RestrictContacts; type_ = Type::RestrictContacts;
@ -82,11 +80,12 @@ UserPrivacySettingRule::UserPrivacySettingRule(const td_api::UserPrivacySettingR
break; break;
case td_api::userPrivacySettingRuleRestrictChatMembers::ID: case td_api::userPrivacySettingRuleRestrictChatMembers::ID:
type_ = Type::RestrictChatParticipants; type_ = Type::RestrictChatParticipants;
set_chat_ids(static_cast<const td_api::userPrivacySettingRuleRestrictChatMembers &>(rule).chat_ids_); set_chat_ids(td, static_cast<const td_api::userPrivacySettingRuleRestrictChatMembers &>(rule).chat_ids_);
break; break;
default: default:
UNREACHABLE(); UNREACHABLE();
} }
td::remove_if(user_ids_, [](UserId user_id) { return !user_id.is_valid(); });
} }
UserPrivacySettingRule::UserPrivacySettingRule(const telegram_api::PrivacyRule &rule) { UserPrivacySettingRule::UserPrivacySettingRule(const telegram_api::PrivacyRule &rule) {
@ -127,8 +126,8 @@ UserPrivacySettingRule::UserPrivacySettingRule(const telegram_api::PrivacyRule &
} }
} }
td_api::object_ptr<td_api::UserPrivacySettingRule> UserPrivacySettingRule::get_user_privacy_setting_rule_object() td_api::object_ptr<td_api::UserPrivacySettingRule> UserPrivacySettingRule::get_user_privacy_setting_rule_object(
const { Td *td) const {
switch (type_) { switch (type_) {
case Type::AllowContacts: case Type::AllowContacts:
return make_tl_object<td_api::userPrivacySettingRuleAllowContacts>(); return make_tl_object<td_api::userPrivacySettingRuleAllowContacts>();
@ -137,23 +136,25 @@ td_api::object_ptr<td_api::UserPrivacySettingRule> UserPrivacySettingRule::get_u
case Type::AllowAll: case Type::AllowAll:
return make_tl_object<td_api::userPrivacySettingRuleAllowAll>(); return make_tl_object<td_api::userPrivacySettingRuleAllowAll>();
case Type::AllowUsers: case Type::AllowUsers:
return make_tl_object<td_api::userPrivacySettingRuleAllowUsers>(UserId::get_input_user_ids(user_ids_)); return make_tl_object<td_api::userPrivacySettingRuleAllowUsers>(
td->contacts_manager_->get_user_ids_object(user_ids_, "userPrivacySettingRuleAllowUsers"));
case Type::AllowChatParticipants: case Type::AllowChatParticipants:
return make_tl_object<td_api::userPrivacySettingRuleAllowChatMembers>(chat_ids_as_dialog_ids()); return make_tl_object<td_api::userPrivacySettingRuleAllowChatMembers>(chat_ids_as_dialog_ids(td));
case Type::RestrictContacts: case Type::RestrictContacts:
return make_tl_object<td_api::userPrivacySettingRuleRestrictContacts>(); return make_tl_object<td_api::userPrivacySettingRuleRestrictContacts>();
case Type::RestrictAll: case Type::RestrictAll:
return make_tl_object<td_api::userPrivacySettingRuleRestrictAll>(); return make_tl_object<td_api::userPrivacySettingRuleRestrictAll>();
case Type::RestrictUsers: case Type::RestrictUsers:
return make_tl_object<td_api::userPrivacySettingRuleRestrictUsers>(UserId::get_input_user_ids(user_ids_)); return make_tl_object<td_api::userPrivacySettingRuleRestrictUsers>(
td->contacts_manager_->get_user_ids_object(user_ids_, "userPrivacySettingRuleRestrictUsers"));
case Type::RestrictChatParticipants: case Type::RestrictChatParticipants:
return make_tl_object<td_api::userPrivacySettingRuleRestrictChatMembers>(chat_ids_as_dialog_ids()); return make_tl_object<td_api::userPrivacySettingRuleRestrictChatMembers>(chat_ids_as_dialog_ids(td));
default: default:
UNREACHABLE(); UNREACHABLE();
} }
} }
telegram_api::object_ptr<telegram_api::InputPrivacyRule> UserPrivacySettingRule::get_input_privacy_rule() const { telegram_api::object_ptr<telegram_api::InputPrivacyRule> UserPrivacySettingRule::get_input_privacy_rule(Td *td) const {
switch (type_) { switch (type_) {
case Type::AllowContacts: case Type::AllowContacts:
return make_tl_object<telegram_api::inputPrivacyValueAllowContacts>(); return make_tl_object<telegram_api::inputPrivacyValueAllowContacts>();
@ -162,7 +163,7 @@ telegram_api::object_ptr<telegram_api::InputPrivacyRule> UserPrivacySettingRule:
case Type::AllowAll: case Type::AllowAll:
return make_tl_object<telegram_api::inputPrivacyValueAllowAll>(); return make_tl_object<telegram_api::inputPrivacyValueAllowAll>();
case Type::AllowUsers: case Type::AllowUsers:
return make_tl_object<telegram_api::inputPrivacyValueAllowUsers>(get_input_users()); return make_tl_object<telegram_api::inputPrivacyValueAllowUsers>(get_input_users(td));
case Type::AllowChatParticipants: case Type::AllowChatParticipants:
return make_tl_object<telegram_api::inputPrivacyValueAllowChatParticipants>(vector<int64>{chat_ids_}); return make_tl_object<telegram_api::inputPrivacyValueAllowChatParticipants>(vector<int64>{chat_ids_});
case Type::RestrictContacts: case Type::RestrictContacts:
@ -170,7 +171,7 @@ telegram_api::object_ptr<telegram_api::InputPrivacyRule> UserPrivacySettingRule:
case Type::RestrictAll: case Type::RestrictAll:
return make_tl_object<telegram_api::inputPrivacyValueDisallowAll>(); return make_tl_object<telegram_api::inputPrivacyValueDisallowAll>();
case Type::RestrictUsers: case Type::RestrictUsers:
return make_tl_object<telegram_api::inputPrivacyValueDisallowUsers>(get_input_users()); return make_tl_object<telegram_api::inputPrivacyValueDisallowUsers>(get_input_users(td));
case Type::RestrictChatParticipants: case Type::RestrictChatParticipants:
return make_tl_object<telegram_api::inputPrivacyValueDisallowChatParticipants>(vector<int64>{chat_ids_}); return make_tl_object<telegram_api::inputPrivacyValueDisallowChatParticipants>(vector<int64>{chat_ids_});
default: default:
@ -179,10 +180,9 @@ telegram_api::object_ptr<telegram_api::InputPrivacyRule> UserPrivacySettingRule:
} }
Result<UserPrivacySettingRule> UserPrivacySettingRule::get_user_privacy_setting_rule( Result<UserPrivacySettingRule> UserPrivacySettingRule::get_user_privacy_setting_rule(
telegram_api::object_ptr<telegram_api::PrivacyRule> rule) { Td *td, telegram_api::object_ptr<telegram_api::PrivacyRule> rule) {
CHECK(rule != nullptr); CHECK(rule != nullptr);
UserPrivacySettingRule result(*rule); UserPrivacySettingRule result(*rule);
auto td = G()->td().get_actor_unsafe();
for (auto user_id : result.user_ids_) { for (auto user_id : result.user_ids_) {
if (!td->contacts_manager_->have_user(user_id)) { if (!td->contacts_manager_->have_user(user_id)) {
return Status::Error(500, "Receive inaccessible user from the server"); return Status::Error(500, "Receive inaccessible user from the server");
@ -203,10 +203,10 @@ Result<UserPrivacySettingRule> UserPrivacySettingRule::get_user_privacy_setting_
return result; return result;
} }
vector<telegram_api::object_ptr<telegram_api::InputUser>> UserPrivacySettingRule::get_input_users() const { vector<telegram_api::object_ptr<telegram_api::InputUser>> UserPrivacySettingRule::get_input_users(Td *td) const {
vector<telegram_api::object_ptr<telegram_api::InputUser>> result; vector<telegram_api::object_ptr<telegram_api::InputUser>> result;
for (auto user_id : user_ids_) { for (auto user_id : user_ids_) {
auto r_input_user = G()->td().get_actor_unsafe()->contacts_manager_->get_input_user(user_id); auto r_input_user = td->contacts_manager_->get_input_user(user_id);
if (r_input_user.is_ok()) { if (r_input_user.is_ok()) {
result.push_back(r_input_user.move_as_ok()); result.push_back(r_input_user.move_as_ok());
} else { } else {
@ -216,9 +216,8 @@ vector<telegram_api::object_ptr<telegram_api::InputUser>> UserPrivacySettingRule
return result; return result;
} }
vector<int64> UserPrivacySettingRule::chat_ids_as_dialog_ids() const { vector<int64> UserPrivacySettingRule::chat_ids_as_dialog_ids(Td *td) const {
vector<int64> result; vector<int64> result;
auto td = G()->td().get_actor_unsafe();
for (auto chat_id_int : chat_ids_) { for (auto chat_id_int : chat_ids_) {
ChatId chat_id(chat_id_int); ChatId chat_id(chat_id_int);
DialogId dialog_id(chat_id); DialogId dialog_id(chat_id);
@ -241,20 +240,20 @@ vector<UserId> UserPrivacySettingRule::get_restricted_user_ids() const {
} }
Result<UserPrivacySettingRules> UserPrivacySettingRules::get_user_privacy_setting_rules( Result<UserPrivacySettingRules> UserPrivacySettingRules::get_user_privacy_setting_rules(
telegram_api::object_ptr<telegram_api::account_privacyRules> rules) { Td *td, telegram_api::object_ptr<telegram_api::account_privacyRules> rules) {
G()->td().get_actor_unsafe()->contacts_manager_->on_get_users(std::move(rules->users_), "on get privacy rules"); td->contacts_manager_->on_get_users(std::move(rules->users_), "on get privacy rules");
G()->td().get_actor_unsafe()->contacts_manager_->on_get_chats(std::move(rules->chats_), "on get privacy rules"); td->contacts_manager_->on_get_chats(std::move(rules->chats_), "on get privacy rules");
return get_user_privacy_setting_rules(std::move(rules->rules_)); return get_user_privacy_setting_rules(td, std::move(rules->rules_));
} }
Result<UserPrivacySettingRules> UserPrivacySettingRules::get_user_privacy_setting_rules( Result<UserPrivacySettingRules> UserPrivacySettingRules::get_user_privacy_setting_rules(
vector<telegram_api::object_ptr<telegram_api::PrivacyRule>> rules) { Td *td, vector<telegram_api::object_ptr<telegram_api::PrivacyRule>> rules) {
UserPrivacySettingRules result; UserPrivacySettingRules result;
for (auto &rule : rules) { for (auto &rule : rules) {
TRY_RESULT(new_rule, UserPrivacySettingRule::get_user_privacy_setting_rule(std::move(rule))); TRY_RESULT(new_rule, UserPrivacySettingRule::get_user_privacy_setting_rule(td, std::move(rule)));
result.rules_.push_back(new_rule); result.rules_.push_back(new_rule);
} }
if (!result.rules_.empty() && result.rules_.back().get_user_privacy_setting_rule_object()->get_id() == if (!result.rules_.empty() && result.rules_.back().get_user_privacy_setting_rule_object(td)->get_id() ==
td_api::userPrivacySettingRuleRestrictAll::ID) { td_api::userPrivacySettingRuleRestrictAll::ID) {
result.rules_.pop_back(); result.rules_.pop_back();
} }
@ -262,7 +261,7 @@ Result<UserPrivacySettingRules> UserPrivacySettingRules::get_user_privacy_settin
} }
Result<UserPrivacySettingRules> UserPrivacySettingRules::get_user_privacy_setting_rules( Result<UserPrivacySettingRules> UserPrivacySettingRules::get_user_privacy_setting_rules(
td_api::object_ptr<td_api::userPrivacySettingRules> rules) { Td *td, td_api::object_ptr<td_api::userPrivacySettingRules> rules) {
if (rules == nullptr) { if (rules == nullptr) {
return Status::Error(400, "UserPrivacySettingRules must be non-empty"); return Status::Error(400, "UserPrivacySettingRules must be non-empty");
} }
@ -271,20 +270,20 @@ Result<UserPrivacySettingRules> UserPrivacySettingRules::get_user_privacy_settin
if (rule == nullptr) { if (rule == nullptr) {
return Status::Error(400, "UserPrivacySettingRule must be non-empty"); return Status::Error(400, "UserPrivacySettingRule must be non-empty");
} }
result.rules_.emplace_back(*rule); result.rules_.emplace_back(td, *rule);
} }
return result; return result;
} }
td_api::object_ptr<td_api::userPrivacySettingRules> UserPrivacySettingRules::get_user_privacy_setting_rules_object() td_api::object_ptr<td_api::userPrivacySettingRules> UserPrivacySettingRules::get_user_privacy_setting_rules_object(
const { Td *td) const {
return make_tl_object<td_api::userPrivacySettingRules>( return make_tl_object<td_api::userPrivacySettingRules>(
transform(rules_, [](const auto &rule) { return rule.get_user_privacy_setting_rule_object(); })); transform(rules_, [td](const auto &rule) { return rule.get_user_privacy_setting_rule_object(td); }));
} }
vector<telegram_api::object_ptr<telegram_api::InputPrivacyRule>> UserPrivacySettingRules::get_input_privacy_rules() vector<telegram_api::object_ptr<telegram_api::InputPrivacyRule>> UserPrivacySettingRules::get_input_privacy_rules(
const { Td *td) const {
auto result = transform(rules_, [](const auto &rule) { return rule.get_input_privacy_rule(); }); auto result = transform(rules_, [td](const auto &rule) { return rule.get_input_privacy_rule(td); });
if (!result.empty() && result.back()->get_id() == telegram_api::inputPrivacyValueDisallowAll::ID) { if (!result.empty() && result.back()->get_id() == telegram_api::inputPrivacyValueDisallowAll::ID) {
result.pop_back(); result.pop_back();
} }

View File

@ -15,18 +15,20 @@
namespace td { namespace td {
class Td;
class UserPrivacySettingRule { class UserPrivacySettingRule {
public: public:
UserPrivacySettingRule() = default; UserPrivacySettingRule() = default;
explicit UserPrivacySettingRule(const td_api::UserPrivacySettingRule &rule); UserPrivacySettingRule(Td *td, const td_api::UserPrivacySettingRule &rule);
static Result<UserPrivacySettingRule> get_user_privacy_setting_rule( static Result<UserPrivacySettingRule> get_user_privacy_setting_rule(
telegram_api::object_ptr<telegram_api::PrivacyRule> rule); Td *td, telegram_api::object_ptr<telegram_api::PrivacyRule> rule);
td_api::object_ptr<td_api::UserPrivacySettingRule> get_user_privacy_setting_rule_object() const; td_api::object_ptr<td_api::UserPrivacySettingRule> get_user_privacy_setting_rule_object(Td *td) const;
telegram_api::object_ptr<telegram_api::InputPrivacyRule> get_input_privacy_rule() const; telegram_api::object_ptr<telegram_api::InputPrivacyRule> get_input_privacy_rule(Td *td) const;
bool operator==(const UserPrivacySettingRule &other) const { bool operator==(const UserPrivacySettingRule &other) const {
return type_ == other.type_ && user_ids_ == other.user_ids_ && chat_ids_ == other.chat_ids_; return type_ == other.type_ && user_ids_ == other.user_ids_ && chat_ids_ == other.chat_ids_;
@ -50,11 +52,11 @@ class UserPrivacySettingRule {
vector<UserId> user_ids_; vector<UserId> user_ids_;
vector<int64> chat_ids_; vector<int64> chat_ids_;
vector<telegram_api::object_ptr<telegram_api::InputUser>> get_input_users() const; vector<telegram_api::object_ptr<telegram_api::InputUser>> get_input_users(Td *td) const;
void set_chat_ids(const vector<int64> &dialog_ids); void set_chat_ids(Td *td, const vector<int64> &dialog_ids);
vector<int64> chat_ids_as_dialog_ids() const; vector<int64> chat_ids_as_dialog_ids(Td *td) const;
explicit UserPrivacySettingRule(const telegram_api::PrivacyRule &rule); explicit UserPrivacySettingRule(const telegram_api::PrivacyRule &rule);
}; };
@ -64,17 +66,17 @@ class UserPrivacySettingRules {
UserPrivacySettingRules() = default; UserPrivacySettingRules() = default;
static Result<UserPrivacySettingRules> get_user_privacy_setting_rules( static Result<UserPrivacySettingRules> get_user_privacy_setting_rules(
telegram_api::object_ptr<telegram_api::account_privacyRules> rules); Td *td, telegram_api::object_ptr<telegram_api::account_privacyRules> rules);
static Result<UserPrivacySettingRules> get_user_privacy_setting_rules( static Result<UserPrivacySettingRules> get_user_privacy_setting_rules(
vector<telegram_api::object_ptr<telegram_api::PrivacyRule>> rules); Td *td, vector<telegram_api::object_ptr<telegram_api::PrivacyRule>> rules);
static Result<UserPrivacySettingRules> get_user_privacy_setting_rules( static Result<UserPrivacySettingRules> get_user_privacy_setting_rules(
td_api::object_ptr<td_api::userPrivacySettingRules> rules); Td *td, td_api::object_ptr<td_api::userPrivacySettingRules> rules);
td_api::object_ptr<td_api::userPrivacySettingRules> get_user_privacy_setting_rules_object() const; td_api::object_ptr<td_api::userPrivacySettingRules> get_user_privacy_setting_rules_object(Td *td) const;
vector<telegram_api::object_ptr<telegram_api::InputPrivacyRule>> get_input_privacy_rules() const; vector<telegram_api::object_ptr<telegram_api::InputPrivacyRule>> get_input_privacy_rules(Td *td) const;
bool operator==(const UserPrivacySettingRules &other) const { bool operator==(const UserPrivacySettingRules &other) const {
return rules_ == other.rules_; return rules_ == other.rules_;