mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 14:38:15 +00:00
Prepare legacy group restrictions checking.
This commit is contained in:
@@ -89,6 +89,22 @@ inline auto AdminRightValue(
|
||||
return SingleFlagValue(AdminRightsValue(channel), flag);
|
||||
}
|
||||
|
||||
inline auto AdminRightsValue(not_null<ChatData*> chat) {
|
||||
return chat->adminRightsValue();
|
||||
}
|
||||
|
||||
inline auto AdminRightsValue(
|
||||
not_null<ChatData*> chat,
|
||||
MTPDchatAdminRights::Flags mask) {
|
||||
return FlagsValueWithMask(AdminRightsValue(chat), mask);
|
||||
}
|
||||
|
||||
inline auto AdminRightValue(
|
||||
not_null<ChatData*> chat,
|
||||
MTPDchatAdminRights::Flag flag) {
|
||||
return SingleFlagValue(AdminRightsValue(chat), flag);
|
||||
}
|
||||
|
||||
inline auto RestrictionsValue(not_null<ChannelData*> channel) {
|
||||
return channel->restrictionsValue();
|
||||
}
|
||||
@@ -105,6 +121,38 @@ inline auto RestrictionValue(
|
||||
return SingleFlagValue(RestrictionsValue(channel), flag);
|
||||
}
|
||||
|
||||
inline auto DefaultRestrictionsValue(not_null<ChannelData*> channel) {
|
||||
return channel->defaultRestrictionsValue();
|
||||
}
|
||||
|
||||
inline auto DefaultRestrictionsValue(
|
||||
not_null<ChannelData*> channel,
|
||||
MTPDchatBannedRights::Flags mask) {
|
||||
return FlagsValueWithMask(DefaultRestrictionsValue(channel), mask);
|
||||
}
|
||||
|
||||
inline auto DefaultRestrictionValue(
|
||||
not_null<ChannelData*> channel,
|
||||
MTPDchatBannedRights::Flag flag) {
|
||||
return SingleFlagValue(DefaultRestrictionsValue(channel), flag);
|
||||
}
|
||||
|
||||
inline auto DefaultRestrictionsValue(not_null<ChatData*> chat) {
|
||||
return chat->defaultRestrictionsValue();
|
||||
}
|
||||
|
||||
inline auto DefaultRestrictionsValue(
|
||||
not_null<ChatData*> chat,
|
||||
MTPDchatBannedRights::Flags mask) {
|
||||
return FlagsValueWithMask(DefaultRestrictionsValue(chat), mask);
|
||||
}
|
||||
|
||||
inline auto DefaultRestrictionValue(
|
||||
not_null<ChatData*> chat,
|
||||
MTPDchatBannedRights::Flag flag) {
|
||||
return SingleFlagValue(DefaultRestrictionsValue(chat), flag);
|
||||
}
|
||||
|
||||
rpl::producer<bool> PeerFlagValue(
|
||||
ChatData *chat,
|
||||
MTPDchat_ClientFlag flag) {
|
||||
@@ -125,17 +173,36 @@ rpl::producer<bool> CanWriteValue(UserData *user) {
|
||||
|
||||
rpl::producer<bool> CanWriteValue(ChatData *chat) {
|
||||
using namespace rpl::mappers;
|
||||
auto mask = 0
|
||||
const auto mask = 0
|
||||
| MTPDchat::Flag::f_deactivated
|
||||
| MTPDchat_ClientFlag::f_forbidden
|
||||
| MTPDchat::Flag::f_left
|
||||
| MTPDchat::Flag::f_creator
|
||||
| MTPDchat::Flag::f_kicked;
|
||||
return PeerFlagsValue(chat, mask)
|
||||
| rpl::map(!_1);
|
||||
return rpl::combine(
|
||||
PeerFlagsValue(chat, mask),
|
||||
AdminRightsValue(chat),
|
||||
DefaultRestrictionValue(
|
||||
chat,
|
||||
MTPDchatBannedRights::Flag::f_send_messages),
|
||||
[](
|
||||
MTPDchat::Flags flags,
|
||||
Data::Flags<ChatAdminRights>::Change adminRights,
|
||||
bool defaultSendMessagesRestriction) {
|
||||
const auto actionsUnavailableFlags = 0
|
||||
| MTPDchat::Flag::f_deactivated
|
||||
| MTPDchat_ClientFlag::f_forbidden
|
||||
| MTPDchat::Flag::f_left
|
||||
| MTPDchat::Flag::f_kicked;
|
||||
return !(flags & actionsUnavailableFlags)
|
||||
&& ((flags & MTPDchat::Flag::f_creator)
|
||||
|| (adminRights.value != MTPDchatAdminRights::Flags(0))
|
||||
|| !defaultSendMessagesRestriction);
|
||||
});
|
||||
}
|
||||
|
||||
rpl::producer<bool> CanWriteValue(ChannelData *channel) {
|
||||
auto mask = 0
|
||||
const auto mask = 0
|
||||
| MTPDchannel::Flag::f_left
|
||||
| MTPDchannel_ClientFlag::f_forbidden
|
||||
| MTPDchannel::Flag::f_creator
|
||||
@@ -148,18 +215,23 @@ rpl::producer<bool> CanWriteValue(ChannelData *channel) {
|
||||
RestrictionValue(
|
||||
channel,
|
||||
MTPDchatBannedRights::Flag::f_send_messages),
|
||||
DefaultRestrictionValue(
|
||||
channel,
|
||||
MTPDchatBannedRights::Flag::f_send_messages),
|
||||
[](
|
||||
MTPDchannel::Flags flags,
|
||||
bool postMessagesRight,
|
||||
bool sendMessagesRestriction) {
|
||||
auto notAmInFlags = 0
|
||||
bool sendMessagesRestriction,
|
||||
bool defaultSendMessagesRestriction) {
|
||||
const auto notAmInFlags = 0
|
||||
| MTPDchannel::Flag::f_left
|
||||
| MTPDchannel_ClientFlag::f_forbidden;
|
||||
return !(flags & notAmInFlags)
|
||||
&& (postMessagesRight
|
||||
|| (flags & MTPDchannel::Flag::f_creator)
|
||||
|| (!(flags & MTPDchannel::Flag::f_broadcast)
|
||||
&& !sendMessagesRestriction));
|
||||
&& !sendMessagesRestriction
|
||||
&& !defaultSendMessagesRestriction));
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user