mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Implement private chat noforward following.
This commit is contained in:
@@ -1713,8 +1713,8 @@ void PeerData::processTopics(const MTPVector<MTPForumTopic> &topics) {
|
||||
}
|
||||
|
||||
bool PeerData::allowsForwarding() const {
|
||||
if (isUser()) {
|
||||
return true;
|
||||
if (const auto user = asUser()) {
|
||||
return user->allowsForwarding();
|
||||
} else if (const auto channel = asChannel()) {
|
||||
return channel->allowsForwarding();
|
||||
} else if (const auto chat = asChat()) {
|
||||
|
||||
@@ -646,6 +646,18 @@ bool UserData::readDatesPrivate() const {
|
||||
return (flags() & UserDataFlag::ReadDatesPrivate);
|
||||
}
|
||||
|
||||
bool UserData::allowsForwarding() const {
|
||||
return !(flags() & Flag::NoForwardsMyEnabled)
|
||||
&& !(flags() & Flag::NoForwardsPeerEnabled);
|
||||
}
|
||||
|
||||
void UserData::setNoForwardsFlags(bool myEnabled, bool peerEnabled) {
|
||||
const auto mask = Flag::NoForwardsMyEnabled | Flag::NoForwardsPeerEnabled;
|
||||
setFlags((flags() & ~mask)
|
||||
| (myEnabled ? Flag::NoForwardsMyEnabled : Flag())
|
||||
| (peerEnabled ? Flag::NoForwardsPeerEnabled : Flag()));
|
||||
}
|
||||
|
||||
int UserData::starsPerMessage() const {
|
||||
return _starsPerMessage;
|
||||
}
|
||||
@@ -1036,6 +1048,10 @@ void ApplyUserUpdate(not_null<UserData*> user, const MTPDuserFull &update) {
|
||||
user->setNote(TextWithEntities());
|
||||
}
|
||||
|
||||
user->setNoForwardsFlags(
|
||||
update.is_noforwards_my_enabled(),
|
||||
update.is_noforwards_peer_enabled());
|
||||
|
||||
user->fullUpdated();
|
||||
}
|
||||
|
||||
|
||||
@@ -135,6 +135,8 @@ enum class UserDataFlag : uint32 {
|
||||
StoriesCorrespondent = (1 << 26),
|
||||
Forum = (1 << 27),
|
||||
HasActiveVideoStream = (1 << 28),
|
||||
NoForwardsMyEnabled = (1 << 29),
|
||||
NoForwardsPeerEnabled = (1 << 30),
|
||||
};
|
||||
inline constexpr bool is_flag_type(UserDataFlag) { return true; };
|
||||
using UserDataFlags = base::flags<UserDataFlag>;
|
||||
@@ -201,6 +203,8 @@ public:
|
||||
[[nodiscard]] bool messageMoneyRestrictionsKnown() const;
|
||||
[[nodiscard]] bool canSendIgnoreMoneyRestrictions() const;
|
||||
[[nodiscard]] bool readDatesPrivate() const;
|
||||
[[nodiscard]] bool allowsForwarding() const;
|
||||
void setNoForwardsFlags(bool myEnabled, bool peerEnabled);
|
||||
[[nodiscard]] bool isForum() const {
|
||||
return flags() & Flag::Forum;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user