mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-09-05 08:55:59 +00:00
Added initial api support of reactions limit in channels and groups.
This commit is contained in:
@@ -75,6 +75,10 @@ std::optional<QString> OnlineTextCommon(LastseenStatus status, TimeId now) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
[[nodiscard]] int UniqueReactionsLimit(not_null<Main::AppConfig*> config) {
|
||||
return config->get<int>("reactions_uniq_max", 11);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
inline auto AdminRightsValue(not_null<ChannelData*> channel) {
|
||||
@@ -562,21 +566,45 @@ const AllowedReactions &PeerAllowedReactions(not_null<PeerData*> peer) {
|
||||
});
|
||||
}
|
||||
|
||||
int UniqueReactionsLimit(not_null<Main::AppConfig*> config) {
|
||||
return config->get<int>("reactions_uniq_max", 11);
|
||||
}
|
||||
|
||||
int UniqueReactionsLimit(not_null<PeerData*> peer) {
|
||||
if (const auto channel = peer->asChannel()) {
|
||||
if (const auto limit = channel->allowedReactions().maxCount) {
|
||||
return limit;
|
||||
}
|
||||
} else if (const auto chat = peer->asChat()) {
|
||||
if (const auto limit = chat->allowedReactions().maxCount) {
|
||||
return limit;
|
||||
}
|
||||
}
|
||||
return UniqueReactionsLimit(&peer->session().appConfig());
|
||||
}
|
||||
|
||||
rpl::producer<int> UniqueReactionsLimitValue(
|
||||
not_null<PeerData*> peer) {
|
||||
const auto config = &peer->session().appConfig();
|
||||
return config->value(
|
||||
) | rpl::map([=] {
|
||||
auto configValue = peer->session().appConfig().value(
|
||||
) | rpl::map([config = &peer->session().appConfig()] {
|
||||
return UniqueReactionsLimit(config);
|
||||
}) | rpl::distinct_until_changed();
|
||||
if (const auto channel = peer->asChannel()) {
|
||||
return rpl::combine(
|
||||
PeerAllowedReactionsValue(peer),
|
||||
std::move(configValue)
|
||||
) | rpl::map([=](const auto &allowedReactions, int limit) {
|
||||
return allowedReactions.maxCount
|
||||
? allowedReactions.maxCount
|
||||
: limit;
|
||||
});
|
||||
} else if (const auto chat = peer->asChat()) {
|
||||
return rpl::combine(
|
||||
PeerAllowedReactionsValue(peer),
|
||||
std::move(configValue)
|
||||
) | rpl::map([=](const auto &allowedReactions, int limit) {
|
||||
return allowedReactions.maxCount
|
||||
? allowedReactions.maxCount
|
||||
: limit;
|
||||
});
|
||||
}
|
||||
return configValue;
|
||||
}
|
||||
|
||||
} // namespace Data
|
||||
|
Reference in New Issue
Block a user