// // Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024 // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #include "td/telegram/UserPrivacySetting.h" namespace td { Result UserPrivacySetting::get_user_privacy_setting( td_api::object_ptr key) { if (key == nullptr) { return Status::Error(400, "UserPrivacySetting must be non-empty"); } return UserPrivacySetting(*key); } UserPrivacySetting::UserPrivacySetting(const telegram_api::PrivacyKey &key) { switch (key.get_id()) { case telegram_api::privacyKeyStatusTimestamp::ID: type_ = Type::UserStatus; break; case telegram_api::privacyKeyChatInvite::ID: type_ = Type::ChatInvite; break; case telegram_api::privacyKeyPhoneCall::ID: type_ = Type::Call; break; case telegram_api::privacyKeyPhoneP2P::ID: type_ = Type::PeerToPeerCall; break; case telegram_api::privacyKeyForwards::ID: type_ = Type::LinkInForwardedMessages; break; case telegram_api::privacyKeyProfilePhoto::ID: type_ = Type::UserProfilePhoto; break; case telegram_api::privacyKeyPhoneNumber::ID: type_ = Type::UserPhoneNumber; break; case telegram_api::privacyKeyAddedByPhone::ID: type_ = Type::FindByPhoneNumber; break; case telegram_api::privacyKeyVoiceMessages::ID: type_ = Type::VoiceMessages; break; case telegram_api::privacyKeyAbout::ID: type_ = Type::UserBio; break; case telegram_api::privacyKeyBirthday::ID: type_ = Type::UserBio; break; default: UNREACHABLE(); type_ = Type::UserStatus; } } td_api::object_ptr UserPrivacySetting::get_user_privacy_setting_object() const { switch (type_) { case Type::UserStatus: return make_tl_object(); case Type::ChatInvite: return make_tl_object(); case Type::Call: return make_tl_object(); case Type::PeerToPeerCall: return make_tl_object(); case Type::LinkInForwardedMessages: return make_tl_object(); case Type::UserProfilePhoto: return make_tl_object(); case Type::UserPhoneNumber: return make_tl_object(); case Type::FindByPhoneNumber: return make_tl_object(); case Type::VoiceMessages: return make_tl_object(); case Type::UserBio: return make_tl_object(); default: UNREACHABLE(); return nullptr; } } telegram_api::object_ptr UserPrivacySetting::get_input_privacy_key() const { switch (type_) { case Type::UserStatus: return make_tl_object(); case Type::ChatInvite: return make_tl_object(); case Type::Call: return make_tl_object(); case Type::PeerToPeerCall: return make_tl_object(); case Type::LinkInForwardedMessages: return make_tl_object(); case Type::UserProfilePhoto: return make_tl_object(); case Type::UserPhoneNumber: return make_tl_object(); case Type::FindByPhoneNumber: return make_tl_object(); case Type::VoiceMessages: return make_tl_object(); case Type::UserBio: return make_tl_object(); default: UNREACHABLE(); return nullptr; } } UserPrivacySetting::UserPrivacySetting(const td_api::UserPrivacySetting &key) { switch (key.get_id()) { case td_api::userPrivacySettingShowStatus::ID: type_ = Type::UserStatus; break; case td_api::userPrivacySettingAllowChatInvites::ID: type_ = Type::ChatInvite; break; case td_api::userPrivacySettingAllowCalls::ID: type_ = Type::Call; break; case td_api::userPrivacySettingAllowPeerToPeerCalls::ID: type_ = Type::PeerToPeerCall; break; case td_api::userPrivacySettingShowLinkInForwardedMessages::ID: type_ = Type::LinkInForwardedMessages; break; case td_api::userPrivacySettingShowProfilePhoto::ID: type_ = Type::UserProfilePhoto; break; case td_api::userPrivacySettingShowPhoneNumber::ID: type_ = Type::UserPhoneNumber; break; case td_api::userPrivacySettingAllowFindingByPhoneNumber::ID: type_ = Type::FindByPhoneNumber; break; case td_api::userPrivacySettingAllowPrivateVoiceAndVideoNoteMessages::ID: type_ = Type::VoiceMessages; break; case td_api::userPrivacySettingShowBio::ID: type_ = Type::UserBio; break; default: UNREACHABLE(); type_ = Type::UserStatus; } } } // namespace td