diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index c460f8ca7..f1d8dbba5 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -3484,6 +3484,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_verification_codes" = "Verification Codes"; "lng_verification_codes_about" = "Third-party services, like websites and stores, can send verification codes to your phone number via Telegram instead of SMS. Such codes will appear in this chat.\n\nIf you didn't request any codes — don't worry! Most likely, someone made a mistake when entering their number."; +"lng_verified_by_telegram" = "This community is verified as official by the representatives of Telegram."; + "lng_archived_name" = "Archived chats"; "lng_archived_add" = "Archive"; "lng_archived_remove" = "Unarchive"; diff --git a/Telegram/SourceFiles/data/data_channel.cpp b/Telegram/SourceFiles/data/data_channel.cpp index 8d3d3797a..6810b0ee9 100644 --- a/Telegram/SourceFiles/data/data_channel.cpp +++ b/Telegram/SourceFiles/data/data_channel.cpp @@ -715,9 +715,6 @@ bool ChannelData::canRestrictParticipant( } void ChannelData::setVerifyDetails(Ui::VerifyDetails details) { - if (_verifyDetails && !verifiedByTelegram() && !details) { - return; AssertIsDebug(); - } if (!details) { if (_verifyDetails) { _verifyDetails = nullptr; diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp index fc3646e27..dc952ddc6 100644 --- a/Telegram/SourceFiles/data/data_session.cpp +++ b/Telegram/SourceFiles/data/data_session.cpp @@ -132,6 +132,21 @@ void CheckForSwitchInlineButton(not_null item) { } } +[[nodiscard]] Ui::VerifyDetails Parse(const MTPBotVerification *info) { + if (!info) { + return {}; + } + const auto &data = info->data(); + auto description = qs(data.vdescription().value_or_empty()); + const auto flags = TextParseLinks; + return { + .botId = UserId(data.vbot_id().v), + .iconBgId = SerializeCustomEmojiId(DocumentId(data.vicon().v)), + .company = qs(data.vcompany()), + .description = TextUtilities::ParseEntities(description, flags), + }; +} + [[nodiscard]] InlineImageLocation FindInlineThumbnail( const QVector &sizes) { const auto i = ranges::find( @@ -347,10 +362,8 @@ Ui::VerifyDetails Session::verifiedByTelegram() { return { .iconBgId = _verifiedByTelegramIconBgId, .iconFgId = _verifiedByTelegramIconFgId, - .description = { - u"This community is verified as official " - "by the representatives of Telegram."_q, - }, + .company = u"Telegram"_q, + .description = { tr::lng_verified_by_telegram(tr::now) }, }; } @@ -597,7 +610,7 @@ not_null Session::processUser(const MTPUser &data) { if (data.is_verified()) { result->setVerifyDetails(verifiedByTelegram()); } else { - result->setVerifyDetails({}); + result->setVerifyDetails(Parse(data.vbot_verification())); } if (minimal) { if (result->input.type() == mtpc_inputPeerEmpty) { @@ -1017,7 +1030,7 @@ not_null Session::processChat(const MTPChat &data) { if (data.is_verified()) { channel->setVerifyDetails(verifiedByTelegram()); } else { - channel->setVerifyDetails({}); + channel->setVerifyDetails(Parse(data.vbot_verification())); } if (!minimal && storiesState) { result->setStoriesState(!storiesState->maxId @@ -2715,35 +2728,6 @@ void Session::unregisterDependentMessage( void Session::registerMessageRandomId(uint64 randomId, FullMsgId itemId) { _messageByRandomId.emplace(randomId, itemId); - - AssertIsDebug(); - if (peerIsChannel(itemId.peer)) { - if (const auto channel = channelLoaded(peerToChannel(itemId.peer))) { - auto colored = std::vector>(); - for (const auto &[id, document] : _documents) { - if (const auto sticker = document->sticker()) { - if (sticker->setType == Data::StickersType::Emoji) { - if (document->emojiUsesTextColor()) { - colored.push_back(document.get()); - } - } - } - } - const auto count = int(colored.size()); - if (count > 1) { - auto index1 = base::RandomIndex(count); - auto index2 = base::RandomIndex(count - 1); - if (index2 >= index1) { - ++index2; - } - channel->setVerifyDetails({ - .iconBgId = QString::number(colored[index1]->id), - .iconFgId = QString::number(colored[index2]->id), - }); - history(channel)->updateChatListEntry(); - } - } - } } void Session::unregisterMessageRandomId(uint64 randomId) { diff --git a/Telegram/SourceFiles/info/profile/info_profile_cover.cpp b/Telegram/SourceFiles/info/profile/info_profile_cover.cpp index b935189e4..02ad4f532 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_cover.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_cover.cpp @@ -302,8 +302,10 @@ Cover::Cover( const auto details = peer->verifyDetails(); return Badge::Content{ .badge = details ? BadgeType::Verified : BadgeType::None, - .emojiStatusId = details->iconBgId.toULongLong(), - .emojiStatusInnerId = details->iconFgId.toULongLong(), + .emojiStatusId = details ? details->iconBgId.toULongLong() : 0, + .emojiStatusInnerId = (details + ? details->iconFgId.toULongLong() + : 0), }; }); } diff --git a/Telegram/SourceFiles/ui/unread_badge.h b/Telegram/SourceFiles/ui/unread_badge.h index 0b1cd6015..2e68869ad 100644 --- a/Telegram/SourceFiles/ui/unread_badge.h +++ b/Telegram/SourceFiles/ui/unread_badge.h @@ -33,8 +33,10 @@ private: }; struct VerifyDetails { + UserId botId = 0; QString iconBgId; QString iconFgId; + QString company; TextWithEntities description; explicit operator bool() const {