mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-09-04 00:15:42 +00:00
Provide unavailable reasons for messages.
This commit is contained in:
@@ -126,30 +126,6 @@ void CheckForSwitchInlineButton(not_null<HistoryItem*> item) {
|
||||
}
|
||||
}
|
||||
|
||||
// We should get a full restriction in "{full}: {reason}" format and we
|
||||
// need to find an "-all" tag in {full}, otherwise ignore this restriction.
|
||||
std::vector<UnavailableReason> ExtractUnavailableReasons(
|
||||
const QVector<MTPRestrictionReason> &restrictions) {
|
||||
return ranges::views::all(
|
||||
restrictions
|
||||
) | ranges::views::filter([](const MTPRestrictionReason &restriction) {
|
||||
return restriction.match([&](const auto &data) {
|
||||
const auto platform = qs(data.vplatform());
|
||||
return false
|
||||
#ifdef OS_MAC_STORE
|
||||
|| (platform == u"ios"_q)
|
||||
#elif defined OS_WIN_STORE // OS_MAC_STORE
|
||||
|| (platform == u"ms"_q)
|
||||
#endif // OS_MAC_STORE || OS_WIN_STORE
|
||||
|| (platform == u"all"_q);
|
||||
});
|
||||
}) | ranges::views::transform([](const MTPRestrictionReason &restriction) {
|
||||
return restriction.match([&](const MTPDrestrictionReason &data) {
|
||||
return UnavailableReason{ qs(data.vreason()), qs(data.vtext()) };
|
||||
});
|
||||
}) | ranges::to_vector;
|
||||
}
|
||||
|
||||
[[nodiscard]] InlineImageLocation FindInlineThumbnail(
|
||||
const QVector<MTPPhotoSize> &sizes) {
|
||||
const auto i = ranges::find(
|
||||
@@ -606,12 +582,8 @@ not_null<UserData*> Session::processUser(const MTPUser &data) {
|
||||
result->input = MTP_inputPeerUser(data.vid(), MTP_long(result->accessHash()));
|
||||
result->inputUser = MTP_inputUser(data.vid(), MTP_long(result->accessHash()));
|
||||
}
|
||||
if (const auto restriction = data.vrestriction_reason()) {
|
||||
result->setUnavailableReasons(
|
||||
ExtractUnavailableReasons(restriction->v));
|
||||
} else {
|
||||
result->setUnavailableReasons({});
|
||||
}
|
||||
result->setUnavailableReasons(Data::UnavailableReason::Extract(
|
||||
data.vrestriction_reason()));
|
||||
}
|
||||
if (data.is_deleted()) {
|
||||
if (!result->phone().isEmpty()) {
|
||||
@@ -915,12 +887,8 @@ not_null<PeerData*> Session::processChat(const MTPChat &data) {
|
||||
channel->setAccessHash(
|
||||
data.vaccess_hash().value_or(channel->access));
|
||||
channel->date = data.vdate().v;
|
||||
if (const auto restriction = data.vrestriction_reason()) {
|
||||
channel->setUnavailableReasons(
|
||||
ExtractUnavailableReasons(restriction->v));
|
||||
} else {
|
||||
channel->setUnavailableReasons({});
|
||||
}
|
||||
channel->setUnavailableReasons(Data::UnavailableReason::Extract(
|
||||
data.vrestriction_reason()));
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user