2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 22:46:10 +00:00

Added initial box for premium gifts.

This commit is contained in:
23rd
2022-07-03 17:56:12 +03:00
committed by John Preston
parent 2a3d72ad2e
commit c7c8ebed13
14 changed files with 407 additions and 5 deletions

View File

@@ -253,6 +253,10 @@ bool UserData::canAddContact() const {
return canShareThisContact() && !isContact();
}
bool UserData::canReceiveGifts() const {
return flags() & UserDataFlag::CanReceiveGifts;
}
bool UserData::canShareThisContactFast() const {
return !_phone.isEmpty();
}
@@ -309,14 +313,19 @@ void ApplyUserUpdate(not_null<UserData*> user, const MTPDuserFull &update) {
if (const auto pinned = update.vpinned_msg_id()) {
SetTopPinnedMessageId(user, pinned->v);
}
const auto canReceiveGifts = (update.vflags().v
& MTPDuserFull::Flag::f_premium_gifts)
&& update.vpremium_gifts();
using Flag = UserDataFlag;
const auto mask = Flag::Blocked
| Flag::HasPhoneCalls
| Flag::PhoneCallsPrivate
| Flag::CanReceiveGifts
| Flag::CanPinMessages;
user->setFlags((user->flags() & ~mask)
| (update.is_phone_calls_private() ? Flag::PhoneCallsPrivate : Flag())
| (update.is_phone_calls_available() ? Flag::HasPhoneCalls : Flag())
| (canReceiveGifts ? Flag::CanReceiveGifts : Flag())
| (update.is_can_pin_message() ? Flag::CanPinMessages : Flag())
| (update.is_blocked() ? Flag::Blocked : Flag()));
user->setIsBlocked(update.is_blocked());