2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Show "premium required" information in chat.

This commit is contained in:
John Preston
2024-01-11 23:20:36 +04:00
parent c765bee0cd
commit e5cda0e2b1
27 changed files with 566 additions and 200 deletions

View File

@@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_peer_values.h"
#include "data/data_user.h"
#include "lang/lang_keys.h"
#include "main/main_session.h"
#include "ui/chat/attach/attach_prepare.h"
namespace {
@@ -113,6 +114,9 @@ bool CanSendAnyOf(
if (const auto user = peer->asUser()) {
if (user->isInaccessible() || user->isRepliesChat()) {
return false;
} else if (user->meRequiresPremiumToWrite()
&& !user->session().premium()) {
return false;
} else if (rights
& ~(ChatRestriction::SendVoiceMessages
| ChatRestriction::SendVideoMessages
@@ -167,6 +171,13 @@ std::optional<QString> RestrictionError(
using Flag = ChatRestriction;
if (const auto restricted = peer->amRestricted(restriction)) {
if (const auto user = peer->asUser()) {
if (user->meRequiresPremiumToWrite()
&& !user->session().premium()) {
return tr::lng_restricted_send_non_premium(
tr::now,
lt_user,
user->shortName());
}
const auto result = (restriction == Flag::SendVoiceMessages)
? tr::lng_restricted_send_voice_messages(
tr::now,