diff --git a/td/telegram/UserPrivacySettingRule.h b/td/telegram/UserPrivacySettingRule.h index 3ec5a3f5a..7784f2162 100644 --- a/td/telegram/UserPrivacySettingRule.h +++ b/td/telegram/UserPrivacySettingRule.h @@ -12,6 +12,7 @@ #include "td/utils/common.h" #include "td/utils/Status.h" +#include "td/utils/tl_helpers.h" namespace td { @@ -36,6 +37,28 @@ class UserPrivacySettingRule { vector get_restricted_user_ids() const; + template + void store(StorerT &storer) const { + td::store(type_, storer); + if (type_ == Type::AllowUsers || type_ == Type::RestrictUsers) { + td::store(user_ids_, storer); + } + if (type_ == Type::AllowChatParticipants || type_ == Type::RestrictChatParticipants) { + td::store(chat_ids_, storer); + } + } + + template + void parse(ParserT &parser) { + td::parse(type_, parser); + if (type_ == Type::AllowUsers || type_ == Type::RestrictUsers) { + td::parse(user_ids_, parser); + } + if (type_ == Type::AllowChatParticipants || type_ == Type::RestrictChatParticipants) { + td::parse(chat_ids_, parser); + } + } + private: enum class Type : int32 { AllowContacts, @@ -84,6 +107,16 @@ class UserPrivacySettingRules { vector get_restricted_user_ids() const; + template + void store(StorerT &storer) const { + td::store(rules_, storer); + } + + template + void parse(ParserT &parser) { + td::parse(rules_, parser); + } + private: vector rules_; };