mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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
|
@ -3484,6 +3484,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_verification_codes" = "Verification Codes";
|
"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_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_name" = "Archived chats";
|
||||||
"lng_archived_add" = "Archive";
|
"lng_archived_add" = "Archive";
|
||||||
"lng_archived_remove" = "Unarchive";
|
"lng_archived_remove" = "Unarchive";
|
||||||
|
|
|
@ -715,9 +715,6 @@ bool ChannelData::canRestrictParticipant(
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelData::setVerifyDetails(Ui::VerifyDetails details) {
|
void ChannelData::setVerifyDetails(Ui::VerifyDetails details) {
|
||||||
if (_verifyDetails && !verifiedByTelegram() && !details) {
|
|
||||||
return; AssertIsDebug();
|
|
||||||
}
|
|
||||||
if (!details) {
|
if (!details) {
|
||||||
if (_verifyDetails) {
|
if (_verifyDetails) {
|
||||||
_verifyDetails = nullptr;
|
_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(
|
[[nodiscard]] InlineImageLocation FindInlineThumbnail(
|
||||||
const QVector<MTPPhotoSize> &sizes) {
|
const QVector<MTPPhotoSize> &sizes) {
|
||||||
const auto i = ranges::find(
|
const auto i = ranges::find(
|
||||||
|
@ -347,10 +362,8 @@ Ui::VerifyDetails Session::verifiedByTelegram() {
|
||||||
return {
|
return {
|
||||||
.iconBgId = _verifiedByTelegramIconBgId,
|
.iconBgId = _verifiedByTelegramIconBgId,
|
||||||
.iconFgId = _verifiedByTelegramIconFgId,
|
.iconFgId = _verifiedByTelegramIconFgId,
|
||||||
.description = {
|
.company = u"Telegram"_q,
|
||||||
u"This community is verified as official "
|
.description = { tr::lng_verified_by_telegram(tr::now) },
|
||||||
"by the representatives of Telegram."_q,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -597,7 +610,7 @@ not_null<UserData*> Session::processUser(const MTPUser &data) {
|
||||||
if (data.is_verified()) {
|
if (data.is_verified()) {
|
||||||
result->setVerifyDetails(verifiedByTelegram());
|
result->setVerifyDetails(verifiedByTelegram());
|
||||||
} else {
|
} else {
|
||||||
result->setVerifyDetails({});
|
result->setVerifyDetails(Parse(data.vbot_verification()));
|
||||||
}
|
}
|
||||||
if (minimal) {
|
if (minimal) {
|
||||||
if (result->input.type() == mtpc_inputPeerEmpty) {
|
if (result->input.type() == mtpc_inputPeerEmpty) {
|
||||||
|
@ -1017,7 +1030,7 @@ not_null<PeerData*> Session::processChat(const MTPChat &data) {
|
||||||
if (data.is_verified()) {
|
if (data.is_verified()) {
|
||||||
channel->setVerifyDetails(verifiedByTelegram());
|
channel->setVerifyDetails(verifiedByTelegram());
|
||||||
} else {
|
} else {
|
||||||
channel->setVerifyDetails({});
|
channel->setVerifyDetails(Parse(data.vbot_verification()));
|
||||||
}
|
}
|
||||||
if (!minimal && storiesState) {
|
if (!minimal && storiesState) {
|
||||||
result->setStoriesState(!storiesState->maxId
|
result->setStoriesState(!storiesState->maxId
|
||||||
|
@ -2715,35 +2728,6 @@ void Session::unregisterDependentMessage(
|
||||||
|
|
||||||
void Session::registerMessageRandomId(uint64 randomId, FullMsgId itemId) {
|
void Session::registerMessageRandomId(uint64 randomId, FullMsgId itemId) {
|
||||||
_messageByRandomId.emplace(randomId, 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) {
|
void Session::unregisterMessageRandomId(uint64 randomId) {
|
||||||
|
|
|
@ -302,8 +302,10 @@ Cover::Cover(
|
||||||
const auto details = peer->verifyDetails();
|
const auto details = peer->verifyDetails();
|
||||||
return Badge::Content{
|
return Badge::Content{
|
||||||
.badge = details ? BadgeType::Verified : BadgeType::None,
|
.badge = details ? BadgeType::Verified : BadgeType::None,
|
||||||
.emojiStatusId = details->iconBgId.toULongLong(),
|
.emojiStatusId = details ? details->iconBgId.toULongLong() : 0,
|
||||||
.emojiStatusInnerId = details->iconFgId.toULongLong(),
|
.emojiStatusInnerId = (details
|
||||||
|
? details->iconFgId.toULongLong()
|
||||||
|
: 0),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,8 +33,10 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
struct VerifyDetails {
|
struct VerifyDetails {
|
||||||
|
UserId botId = 0;
|
||||||
QString iconBgId;
|
QString iconBgId;
|
||||||
QString iconFgId;
|
QString iconFgId;
|
||||||
|
QString company;
|
||||||
TextWithEntities description;
|
TextWithEntities description;
|
||||||
|
|
||||||
explicit operator bool() const {
|
explicit operator bool() const {
|
||||||
|
|
Loading…
Add table
Reference in a new issue