From f438916edff8bcc3cd353a91af6fea4d4eecf3b5 Mon Sep 17 00:00:00 2001 From: RadRussianRus Date: Tue, 1 Oct 2019 23:17:17 +0300 Subject: [PATCH] Show restricted date to user --- Telegram/Resources/langs/lang.strings | 7 ++++++ Telegram/SourceFiles/data/data_peer.cpp | 30 +++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index a8a769906..1e7af8077 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -2238,4 +2238,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "ktg_pinned_message_show" = "Show pinned message"; "ktg_pinned_message_hide" = "Hide pinned message"; +"ktg_restricted_send_message_until" = "The admins of this group restricted you from writing here until {date}, {time}."; +"ktg_restricted_send_media_until" = "The admins of this group restricted you from posting media content here until {date}, {time}."; +"ktg_restricted_send_stickers_until" = "The admins of this group restricted you from posting stickers here until {date}, {time}."; +"ktg_restricted_send_gifs_until" = "The admins of this group restricted you from posting GIFs here until {date}, {time}."; +"ktg_restricted_send_inline_until" = "The admins of this group restricted you from posting inline content here until {date}, {time}."; +"ktg_restricted_send_polls_until" = "The admins of this group restricted you from posting polls here until {date}, {time}."; + // Keys finished diff --git a/Telegram/SourceFiles/data/data_peer.cpp b/Telegram/SourceFiles/data/data_peer.cpp index 0c8d75cd2..efd5c3ad8 100644 --- a/Telegram/SourceFiles/data/data_peer.cpp +++ b/Telegram/SourceFiles/data/data_peer.cpp @@ -750,6 +750,36 @@ std::optional RestrictionError( using Flag = ChatRestriction; if (const auto restricted = peer->amRestricted(restriction)) { const auto all = restricted.isWithEveryone(); + if (!all && const auto channel = peer->asChannel()) { + auto restrictedUntil = channel->restrictedUntil(); + if (restrictedUntil > 0) { + auto restrictedUntilDateTime = base::unixtime::parse(channel->restrictedUntil()); + auto date = restrictedUntilDateTime.toString(qsl("d.MM.yy")); + auto time = restrictedUntilDateTime.toString(cTimeFormat()); + + switch (restriction) { + case Flag::f_send_polls: + return tr::ktg_restricted_send_polls_until( + tr::now, lt_date, date, lt_time, time); + case Flag::f_send_messages: + return tr::ktg_restricted_send_message_until( + tr::now, lt_date, date, lt_time, time); + case Flag::f_send_media: + return tr::ktg_restricted_send_media_until( + tr::now, lt_date, date, lt_time, time); + case Flag::f_send_stickers: + return tr::ktg_restricted_send_stickers_until( + tr::now, lt_date, date, lt_time, time); + case Flag::f_send_gifs: + return tr::ktg_restricted_send_gifs_until( + tr::now, lt_date, date, lt_time, time); + case Flag::f_send_inline: + case Flag::f_send_games: + return tr::ktg_restricted_send_inline_until( + tr::now, lt_date, date, lt_time, time); + } + } + } switch (restriction) { case Flag::f_send_polls: return all