2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 22:46:10 +00:00

Show restricted date to user (#6642)

* Show restricted date to user
* Fixed attach button toast
* Fixed attach button toast in scheduled messages
This commit is contained in:
RadRussianRus
2019-10-07 17:35:22 +03:00
committed by John Preston
parent 5f06279b9a
commit 261a83eda3
4 changed files with 41 additions and 2 deletions

View File

@@ -754,6 +754,38 @@ std::optional<QString> RestrictionError(
using Flag = ChatRestriction;
if (const auto restricted = peer->amRestricted(restriction)) {
const auto all = restricted.isWithEveryone();
const auto channel = peer->asChannel();
if (!all && channel) {
auto restrictedUntil = channel->restrictedUntil();
if (restrictedUntil > 0 && !ChannelData::IsRestrictedForever(restrictedUntil)) {
auto restrictedUntilDateTime = base::unixtime::parse(channel->restrictedUntil());
auto date = restrictedUntilDateTime.toString(qsl("dd.MM.yy"));
auto time = restrictedUntilDateTime.toString(cTimeFormat());
switch (restriction) {
case Flag::f_send_polls:
return tr::lng_restricted_send_polls_until(
tr::now, lt_date, date, lt_time, time);
case Flag::f_send_messages:
return tr::lng_restricted_send_message_until(
tr::now, lt_date, date, lt_time, time);
case Flag::f_send_media:
return tr::lng_restricted_send_media_until(
tr::now, lt_date, date, lt_time, time);
case Flag::f_send_stickers:
return tr::lng_restricted_send_stickers_until(
tr::now, lt_date, date, lt_time, time);
case Flag::f_send_gifs:
return tr::lng_restricted_send_gifs_until(
tr::now, lt_date, date, lt_time, time);
case Flag::f_send_inline:
case Flag::f_send_games:
return tr::lng_restricted_send_inline_until(
tr::now, lt_date, date, lt_time, time);
}
Unexpected("Restriction in Data::RestrictionErrorKey.");
}
}
switch (restriction) {
case Flag::f_send_polls:
return all