mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-03 21:54:05 +02:00
Respect boosts restrictions lifting.
This commit is contained in:
parent
180b14ea36
commit
ea12c2f62c
6 changed files with 35 additions and 11 deletions
|
@ -1742,8 +1742,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_action_giveaway_results#other" = "{count} winners of the giveaway were randomly selected by Telegram and received private messages with giftcodes.";
|
||||
"lng_action_giveaway_results_some" = "Some winners of the giveaway were randomly selected by Telegram and received private messages with giftcodes.";
|
||||
"lng_action_giveaway_results_none" = "No winners of the giveaway could be selected.";
|
||||
"lng_action_boost_apply#one" = "{from} boosted the group.";
|
||||
"lng_action_boost_apply#other" = "{from} boosted the group {count} times.";
|
||||
"lng_action_boost_apply#one" = "{from} boosted the group";
|
||||
"lng_action_boost_apply#other" = "{from} boosted the group {count} times";
|
||||
|
||||
"lng_similar_channels_title" = "Similar channels";
|
||||
"lng_similar_channels_view_all" = "View all";
|
||||
|
|
|
@ -889,7 +889,7 @@ void AddBoostsUnrestrictLabels(
|
|||
labels,
|
||||
st::boostsUnrestrictLabel);
|
||||
label->setMarkedText(
|
||||
TextWithEntities(i ? one : many).append(QString::number(i + 1)),
|
||||
TextWithEntities(i ? many : one).append(QString::number(i + 1)),
|
||||
context);
|
||||
rpl::combine(
|
||||
labels->widthValue(),
|
||||
|
|
|
@ -787,7 +787,10 @@ void ChannelData::setSlowmodeSeconds(int seconds) {
|
|||
}
|
||||
|
||||
TimeId ChannelData::slowmodeLastMessage() const {
|
||||
return (hasAdminRights() || amCreator() || !mgInfo)
|
||||
return (hasAdminRights()
|
||||
|| amCreator()
|
||||
|| unrestrictedByBoosts()
|
||||
|| !mgInfo)
|
||||
? 0
|
||||
: mgInfo->slowmodeLastMessage;
|
||||
}
|
||||
|
@ -822,20 +825,36 @@ int ChannelData::boostsUnrestrict() const {
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool ChannelData::unrestrictedByBoosts() const {
|
||||
if (const auto info = mgInfo.get()) {
|
||||
return (info->boostsUnrestrict > 0)
|
||||
&& (info->boostsApplied >= info->boostsUnrestrict);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
rpl::producer<bool> ChannelData::unrestrictedByBoostsValue() const {
|
||||
return mgInfo
|
||||
? mgInfo->unrestrictedByBoostsChanges.events_starting_with(
|
||||
unrestrictedByBoosts())
|
||||
: (rpl::single(false) | rpl::type_erased());
|
||||
}
|
||||
|
||||
void ChannelData::setBoostsUnrestrict(int applied, int unrestrict) {
|
||||
if (const auto info = mgInfo.get()) {
|
||||
if (info->boostsApplied == applied
|
||||
&& info->boostsUnrestrict == unrestrict) {
|
||||
return;
|
||||
}
|
||||
const auto wasUnrestricted = (info->boostsApplied > 0)
|
||||
&& (info->boostsApplied >= info->boostsUnrestrict);
|
||||
const auto nowUnrestricted = (applied > 0)
|
||||
&& (applied >= unrestrict);
|
||||
const auto wasUnrestricted = unrestrictedByBoosts();
|
||||
info->boostsApplied = applied;
|
||||
info->boostsUnrestrict = unrestrict;
|
||||
const auto nowUnrestricted = unrestrictedByBoosts();
|
||||
if (wasUnrestricted != nowUnrestricted) {
|
||||
session().changes().peerUpdated(this, UpdateFlag::Rights);
|
||||
info->unrestrictedByBoostsChanges.fire_copy(nowUnrestricted);
|
||||
session().changes().peerUpdated(
|
||||
this,
|
||||
UpdateFlag::Rights | UpdateFlag::Slowmode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,6 +114,7 @@ public:
|
|||
base::flat_map<not_null<UserData*>, Restricted> lastRestricted;
|
||||
base::flat_set<not_null<PeerData*>> markupSenders;
|
||||
base::flat_set<not_null<UserData*>> bots;
|
||||
rpl::event_stream<bool> unrestrictedByBoostsChanges;
|
||||
|
||||
// For admin badges, full admins list with ranks.
|
||||
base::flat_map<UserId, QString> admins;
|
||||
|
@ -440,6 +441,7 @@ public:
|
|||
[[nodiscard]] int boostsApplied() const;
|
||||
[[nodiscard]] int boostsUnrestrict() const;
|
||||
[[nodiscard]] bool unrestrictedByBoosts() const;
|
||||
[[nodiscard]] rpl::producer<bool> unrestrictedByBoostsValue() const;
|
||||
void setBoostsUnrestrict(int applied, int unrestrict);
|
||||
|
||||
void setInvitePeek(const QString &hash, TimeId expires);
|
||||
|
|
|
@ -1122,7 +1122,8 @@ Data::RestrictionCheckResult PeerData::amRestricted(
|
|||
: ChatRestrictions(0));
|
||||
return (channel->amCreator() || allowByAdminRights(right, channel))
|
||||
? Result::Allowed()
|
||||
: (defaultRestrictions & right)
|
||||
: ((defaultRestrictions & right)
|
||||
&& !channel->unrestrictedByBoosts())
|
||||
? Result::WithEveryone()
|
||||
: (channel->restrictions() & right)
|
||||
? Result::Explicit()
|
||||
|
|
|
@ -267,11 +267,13 @@ inline auto DefaultRestrictionValue(
|
|||
AdminRightValue(
|
||||
channel,
|
||||
ChatAdminRight::PostMessages),
|
||||
channel->unrestrictedByBoostsValue(),
|
||||
RestrictionsValue(channel, rights),
|
||||
DefaultRestrictionsValue(channel, rights),
|
||||
[=](
|
||||
ChannelDataFlags flags,
|
||||
bool postMessagesRight,
|
||||
bool unrestrictedByBoosts,
|
||||
ChatRestrictions sendRestriction,
|
||||
ChatRestrictions defaultSendRestriction) {
|
||||
const auto notAmInFlags = Flag::Left | Flag::Forbidden;
|
||||
|
@ -281,7 +283,7 @@ inline auto DefaultRestrictionValue(
|
|||
|| ((flags & Flag::HasLink)
|
||||
&& !(flags & Flag::JoinToWrite));
|
||||
const auto restricted = sendRestriction
|
||||
| defaultSendRestriction;
|
||||
| (defaultSendRestriction && !unrestrictedByBoosts);
|
||||
return allowed
|
||||
&& !forumRestriction
|
||||
&& (postMessagesRight
|
||||
|
|
Loading…
Add table
Reference in a new issue