mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Show unofficial app warning.
This commit is contained in:
@@ -1603,6 +1603,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_profile_saved_messages#other" = "{count} saved messages";
|
||||
"lng_profile_peer_gifts#one" = "{count} gift";
|
||||
"lng_profile_peer_gifts#other" = "{count} gifts";
|
||||
"lng_profile_unofficial_warning" = "{icon} {name} uses an unofficial Telegram client — messages to this user may be less secure.";
|
||||
"lng_profile_participants_section" = "Members";
|
||||
"lng_profile_subscribers_section" = "Subscribers";
|
||||
"lng_profile_add_contact" = "Add Contact";
|
||||
|
||||
@@ -892,7 +892,8 @@ void ApplyUserUpdate(not_null<UserData*> user, const MTPDuserFull &update) {
|
||||
: Flag())
|
||||
| (user->starsPerMessage() ? Flag::HasStarsPerMessage : Flag())
|
||||
| Flag::MessageMoneyRestrictionsKnown
|
||||
| Flag::RequiresPremiumToWrite;
|
||||
| Flag::RequiresPremiumToWrite
|
||||
| Flag::UnofficialSecurityRisk;
|
||||
user->setFlags((user->flags() & ~mask)
|
||||
| (update.is_phone_calls_private()
|
||||
? Flag::PhoneCallsPrivate
|
||||
@@ -908,6 +909,9 @@ void ApplyUserUpdate(not_null<UserData*> user, const MTPDuserFull &update) {
|
||||
| Flag::MessageMoneyRestrictionsKnown
|
||||
| (update.is_contact_require_premium()
|
||||
? (Flag::RequiresPremiumToWrite | Flag::HasRequirePremiumToWrite)
|
||||
: Flag())
|
||||
| (update.is_unofficial_security_risk()
|
||||
? Flag::UnofficialSecurityRisk
|
||||
: Flag()));
|
||||
user->setIsBlocked(update.is_blocked());
|
||||
user->setCallsStatus(update.is_phone_calls_private()
|
||||
|
||||
@@ -130,7 +130,7 @@ enum class UserDataFlag : uint32 {
|
||||
DiscardMinPhoto = (1 << 12),
|
||||
Self = (1 << 13),
|
||||
Premium = (1 << 14),
|
||||
//CanReceiveGifts = (1 << 15),
|
||||
UnofficialSecurityRisk = (1 << 15),
|
||||
VoiceMessagesForbidden = (1 << 16),
|
||||
PersonalPhoto = (1 << 17),
|
||||
StoriesHidden = (1 << 18),
|
||||
@@ -303,6 +303,10 @@ public:
|
||||
[[nodiscard]] UserId botManagerId() const;
|
||||
void setBotManagerId(UserId managerId);
|
||||
|
||||
[[nodiscard]] bool unofficialSecurityRisk() const {
|
||||
return flags() & Flag::UnofficialSecurityRisk;
|
||||
}
|
||||
|
||||
[[nodiscard]] MTPInputUser inputUser() const;
|
||||
|
||||
QString firstName;
|
||||
|
||||
@@ -1463,3 +1463,6 @@ infoMusicButtonRipple: universalRippleAnimation;
|
||||
infoMusicButtonPadding: margins(16px, 6px, 13px, 6px);
|
||||
|
||||
memberTagPillPadding: margins(5px, -1px, 5px, 0px);
|
||||
|
||||
infoSecurityRiskIconSize: 16px;
|
||||
infoSecurityRiskIconMargin: margins(0px, 2px, 0px, 0px);
|
||||
|
||||
@@ -33,14 +33,17 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "apiwrap.h"
|
||||
#include "api/api_peer_photo.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "ui/text/custom_emoji_helper.h"
|
||||
#include "ui/text/format_song_document_name.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/checkbox.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
#include "ui/widgets/scroll_area.h"
|
||||
#include "ui/widgets/shadow.h"
|
||||
#include "ui/wrap/fade_wrap.h"
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
#include "ui/wrap/slide_wrap.h"
|
||||
#include "ui/painter.h"
|
||||
#include "ui/vertical_list.h"
|
||||
#include "ui/ui_utility.h"
|
||||
#include "styles/style_info.h"
|
||||
@@ -79,6 +82,68 @@ void AddAboutVerification(
|
||||
}, inner->lifetime());
|
||||
}
|
||||
|
||||
void AddUnofficialSecurityRiskWarning(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
not_null<UserData*> user) {
|
||||
const auto content = container->add(
|
||||
object_ptr<Ui::VerticalLayout>(container));
|
||||
user->session().changes().peerFlagsValue(
|
||||
user,
|
||||
Data::PeerUpdate::Flag::FullInfo
|
||||
) | rpl::on_next([=] {
|
||||
while (content->count()) {
|
||||
delete content->widgetAt(0);
|
||||
}
|
||||
if (user->unofficialSecurityRisk()) {
|
||||
auto helper = Ui::Text::CustomEmojiHelper();
|
||||
auto icon = helper.paletteDependent({
|
||||
.factory = [] {
|
||||
const auto s = st::infoSecurityRiskIconSize;
|
||||
const auto ratio = style::DevicePixelRatio();
|
||||
const auto rect = QRect(0, 0, s, s);
|
||||
auto result = QImage(
|
||||
rect.size() * ratio,
|
||||
QImage::Format_ARGB32_Premultiplied);
|
||||
result.setDevicePixelRatio(ratio);
|
||||
result.fill(Qt::transparent);
|
||||
|
||||
auto p = QPainter(&result);
|
||||
auto hq = PainterHighQualityEnabler(p);
|
||||
p.setPen(Qt::NoPen);
|
||||
p.setBrush(st::attentionButtonFg);
|
||||
p.drawEllipse(rect);
|
||||
|
||||
p.setPen(st::windowFgActive);
|
||||
p.setFont(st::semiboldFont);
|
||||
p.drawText(rect, u"!"_q, style::al_center);
|
||||
|
||||
p.end();
|
||||
return result;
|
||||
},
|
||||
.margin = st::infoSecurityRiskIconMargin,
|
||||
});
|
||||
auto label = object_ptr<Ui::FlatLabel>(
|
||||
content,
|
||||
tr::lng_profile_unofficial_warning(
|
||||
lt_icon,
|
||||
rpl::single(std::move(icon)),
|
||||
lt_name,
|
||||
rpl::single(TextWithEntities{ user->firstName }),
|
||||
tr::marked),
|
||||
st::defaultDividerLabel.label,
|
||||
st::defaultPopupMenu,
|
||||
helper.context([=] { content->update(); }));
|
||||
content->add(object_ptr<Ui::DividerLabel>(
|
||||
content,
|
||||
std::move(label),
|
||||
st::defaultBoxDividerLabelPadding,
|
||||
st::defaultDividerLabel.bar,
|
||||
RectPart::Top | RectPart::Bottom));
|
||||
}
|
||||
content->resizeToWidth(content->width());
|
||||
}, content->lifetime());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
InnerWidget::InnerWidget(
|
||||
@@ -125,6 +190,9 @@ object_ptr<Ui::RpWidget> InnerWidget::setupContent(
|
||||
|
||||
auto result = object_ptr<Ui::VerticalLayout>(parent);
|
||||
setupSavedMusic(result);
|
||||
if (const auto user = _peer->asUser()) {
|
||||
AddUnofficialSecurityRiskWarning(result.data(), user);
|
||||
}
|
||||
if (_topic && _topic->creating()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user