2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +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());

View File

@@ -51,6 +51,7 @@ enum class UserDataFlag {
DiscardMinPhoto = (1 << 12),
Self = (1 << 13),
Premium = (1 << 14),
CanReceiveGifts = (1 << 15),
};
inline constexpr bool is_flag_type(UserDataFlag) { return true; };
using UserDataFlags = base::flags<UserDataFlag>;
@@ -106,6 +107,8 @@ public:
[[nodiscard]] bool canShareThisContact() const;
[[nodiscard]] bool canAddContact() const;
[[nodiscard]] bool canReceiveGifts() const;
// In Data::Session::processUsers() we check only that.
// When actually trying to share contact we perform
// a full check by canShareThisContact() call.