MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / ApplyUserUpdate

Function ApplyUserUpdate

Telegram/SourceFiles/data/data_user.cpp:841–1076  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

839namespace Data {
840
841void ApplyUserUpdate(not_null<UserData*> user, const MTPDuserFull &update) {
842 const auto profilePhoto = update.vprofile_photo()
843 ? user->owner().processPhoto(*update.vprofile_photo()).get()
844 : nullptr;
845 const auto personalPhoto = update.vpersonal_photo()
846 ? user->owner().processPhoto(*update.vpersonal_photo()).get()
847 : nullptr;
848 if (personalPhoto && profilePhoto) {
849 user->session().api().peerPhoto().registerNonPersonalPhoto(
850 user,
851 profilePhoto);
852 } else {
853 user->session().api().peerPhoto().unregisterNonPersonalPhoto(user);
854 }
855 if (const auto photo = update.vfallback_photo()) {
856 const auto data = user->owner().processPhoto(*photo);
857 if (!data->isNull()) { // Sometimes there is photoEmpty :shrug:
858 user->session().storage().add(Storage::UserPhotosSetBack(
859 peerToUser(user->id),
860 data->id
861 ));
862 }
863 }
864 user->setBarSettings(update.vsettings());
865 user->owner().notifySettings().apply(user, update.vnotify_settings());
866
867 user->setMessagesTTL(update.vttl_period().value_or_empty());
868 if (const auto info = update.vbot_info()) {
869 user->setBotInfo(*info);
870 } else {
871 user->setBotInfoVersion(-1);
872 }
873 if (const auto info = user->botInfo.get()) {
874 info->canManageEmojiStatus = update.is_bot_can_manage_emoji_status();
875 user->setStarRefProgram(
876 Data::ParseStarRefProgram(update.vstarref_program()));
877 }
878 if (const auto pinned = update.vpinned_msg_id()) {
879 SetTopPinnedMessageId(user, pinned->v);
880 }
881 user->setStarsPerMessage(
882 update.vsend_paid_messages_stars().value_or_empty());
883 using Flag = UserDataFlag;
884 const auto mask = Flag::Blocked
885 | Flag::HasPhoneCalls
886 | Flag::PhoneCallsPrivate
887 | Flag::CanPinMessages
888 | Flag::VoiceMessagesForbidden
889 | Flag::ReadDatesPrivate
890 | (update.is_contact_require_premium()
891 ? Flag::HasRequirePremiumToWrite
892 : Flag())
893 | (user->starsPerMessage() ? Flag::HasStarsPerMessage : Flag())
894 | Flag::MessageMoneyRestrictionsKnown
895 | Flag::RequiresPremiumToWrite
896 | Flag::UnofficialSecurityRisk;
897 user->setFlags((user->flags() & ~mask)
898 | (update.is_phone_calls_private()

Callers 1

gotUserFullMethod · 0.85

Calls 15

peerToUserFunction · 0.85
ParseStarRefProgramFunction · 0.85
SetTopPinnedMessageIdFunction · 0.85
qsFunction · 0.85
ParseBotVerifyDetailsFunction · 0.85
ParseStarsRatingFunction · 0.85
EntitiesFromMTPFunction · 0.85
TextWithEntitiesClass · 0.85
apiMethod · 0.80
setBarSettingsMethod · 0.80

Tested by

no test coverage detected