mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 15:17:07 +02:00
Apply server side bot verifications.
This commit is contained in:
parent
6f18b9b691
commit
0363421862
5 changed files with 27 additions and 40 deletions
Telegram
Resources/langs
SourceFiles
|
@ -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";
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -132,6 +132,21 @@ void CheckForSwitchInlineButton(not_null<HistoryItem*> 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<MTPPhotoSize> &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<UserData*> 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<PeerData*> 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<not_null<DocumentData*>>();
|
||||
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) {
|
||||
|
|
|
@ -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),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -33,8 +33,10 @@ private:
|
|||
};
|
||||
|
||||
struct VerifyDetails {
|
||||
UserId botId = 0;
|
||||
QString iconBgId;
|
||||
QString iconFgId;
|
||||
QString company;
|
||||
TextWithEntities description;
|
||||
|
||||
explicit operator bool() const {
|
||||
|
|
Loading…
Add table
Reference in a new issue