mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Handle nice topic / post-in-topic links.
This commit is contained in:
parent
3078a94404
commit
18bf5c0ee2
17 changed files with 206 additions and 142 deletions
|
@ -696,15 +696,16 @@ QString ApiWrap::exportDirectMessageLink(
|
||||||
const auto base = linkChannel->hasUsername()
|
const auto base = linkChannel->hasUsername()
|
||||||
? linkChannel->username()
|
? linkChannel->username()
|
||||||
: "c/" + QString::number(peerToChannel(linkChannel->id).bare);
|
: "c/" + QString::number(peerToChannel(linkChannel->id).bare);
|
||||||
|
const auto post = QString::number(linkItemId.bare);
|
||||||
const auto query = base
|
const auto query = base
|
||||||
+ '/'
|
+ '/'
|
||||||
+ QString::number(linkItemId.bare)
|
|
||||||
+ (linkCommentId
|
+ (linkCommentId
|
||||||
? "?comment=" + QString::number(linkCommentId.bare)
|
? (post + "?comment=" + QString::number(linkCommentId.bare))
|
||||||
|
: (linkThreadId && !linkThreadIsTopic)
|
||||||
|
? (post + "?thread=" + QString::number(linkThreadId.bare))
|
||||||
: linkThreadId
|
: linkThreadId
|
||||||
? ((linkThreadIsTopic ? "?topic=" : "?thread=")
|
? (QString::number(linkThreadId.bare) + '/' + post)
|
||||||
+ QString::number(linkThreadId.bare))
|
: post);
|
||||||
: "");
|
|
||||||
if (linkChannel->hasUsername()
|
if (linkChannel->hasUsername()
|
||||||
&& !linkChannel->isMegagroup()
|
&& !linkChannel->isMegagroup()
|
||||||
&& !linkCommentId
|
&& !linkCommentId
|
||||||
|
|
|
@ -139,7 +139,7 @@ bool ShareUrl(
|
||||||
auto params = url_parse_params(
|
auto params = url_parse_params(
|
||||||
match->captured(1),
|
match->captured(1),
|
||||||
qthelp::UrlParamNameTransform::ToLower);
|
qthelp::UrlParamNameTransform::ToLower);
|
||||||
auto url = params.value(qsl("url"));
|
auto url = params.value(u"url"_q);
|
||||||
if (url.isEmpty()) {
|
if (url.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -160,8 +160,8 @@ bool ConfirmPhone(
|
||||||
const auto params = url_parse_params(
|
const auto params = url_parse_params(
|
||||||
match->captured(1),
|
match->captured(1),
|
||||||
qthelp::UrlParamNameTransform::ToLower);
|
qthelp::UrlParamNameTransform::ToLower);
|
||||||
const auto phone = params.value(qsl("phone"));
|
const auto phone = params.value(u"phone"_q);
|
||||||
const auto hash = params.value(qsl("hash"));
|
const auto hash = params.value(u"hash"_q);
|
||||||
if (phone.isEmpty() || hash.isEmpty()) {
|
if (phone.isEmpty() || hash.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@ bool ShareGameScore(
|
||||||
const auto params = url_parse_params(
|
const auto params = url_parse_params(
|
||||||
match->captured(1),
|
match->captured(1),
|
||||||
qthelp::UrlParamNameTransform::ToLower);
|
qthelp::UrlParamNameTransform::ToLower);
|
||||||
ShareGameScoreByHash(controller, params.value(qsl("hash")));
|
ShareGameScoreByHash(controller, params.value(u"hash"_q));
|
||||||
controller->window().activate();
|
controller->window().activate();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -265,16 +265,16 @@ bool ShowWallPaper(
|
||||||
const auto params = url_parse_params(
|
const auto params = url_parse_params(
|
||||||
match->captured(1),
|
match->captured(1),
|
||||||
qthelp::UrlParamNameTransform::ToLower);
|
qthelp::UrlParamNameTransform::ToLower);
|
||||||
const auto bg = params.value("bg_color");
|
const auto bg = params.value(u"bg_color"_q);
|
||||||
const auto color = params.value("color");
|
const auto color = params.value(u"color"_q);
|
||||||
const auto gradient = params.value("gradient");
|
const auto gradient = params.value(u"gradient"_q);
|
||||||
const auto result = BackgroundPreviewBox::Start(
|
const auto result = BackgroundPreviewBox::Start(
|
||||||
controller,
|
controller,
|
||||||
(!color.isEmpty()
|
(!color.isEmpty()
|
||||||
? color
|
? color
|
||||||
: !gradient.isEmpty()
|
: !gradient.isEmpty()
|
||||||
? gradient
|
? gradient
|
||||||
: params.value(qsl("slug"))),
|
: params.value(u"slug"_q)),
|
||||||
params);
|
params);
|
||||||
controller->window().activate();
|
controller->window().activate();
|
||||||
return result;
|
return result;
|
||||||
|
@ -283,7 +283,7 @@ bool ShowWallPaper(
|
||||||
[[nodiscard]] ChatAdminRights ParseRequestedAdminRights(
|
[[nodiscard]] ChatAdminRights ParseRequestedAdminRights(
|
||||||
const QString &value) {
|
const QString &value) {
|
||||||
auto result = ChatAdminRights();
|
auto result = ChatAdminRights();
|
||||||
for (const auto &element : value.split(QRegularExpression("[+ ]"))) {
|
for (const auto &element : value.split(QRegularExpression(u"[+ ]"_q))) {
|
||||||
if (element == u"change_info"_q) {
|
if (element == u"change_info"_q) {
|
||||||
result |= ChatAdminRight::ChangeInfo;
|
result |= ChatAdminRight::ChangeInfo;
|
||||||
} else if (element == u"post_messages"_q) {
|
} else if (element == u"post_messages"_q) {
|
||||||
|
@ -325,19 +325,19 @@ bool ResolveUsernameOrPhone(
|
||||||
const auto params = url_parse_params(
|
const auto params = url_parse_params(
|
||||||
match->captured(1),
|
match->captured(1),
|
||||||
qthelp::UrlParamNameTransform::ToLower);
|
qthelp::UrlParamNameTransform::ToLower);
|
||||||
const auto domain = params.value(qsl("domain"));
|
const auto domain = params.value(u"domain"_q);
|
||||||
const auto phone = params.value(qsl("phone"));
|
const auto phone = params.value(u"phone"_q);
|
||||||
const auto validDomain = [](const QString &domain) {
|
const auto validDomain = [](const QString &domain) {
|
||||||
return qthelp::regex_match(
|
return qthelp::regex_match(
|
||||||
qsl("^[a-zA-Z0-9\\.\\_]+$"),
|
u"^[a-zA-Z0-9\\.\\_]+$"_q,
|
||||||
domain,
|
domain,
|
||||||
{}
|
{}
|
||||||
).valid();
|
).valid();
|
||||||
};
|
};
|
||||||
const auto validPhone = [](const QString &phone) {
|
const auto validPhone = [](const QString &phone) {
|
||||||
return qthelp::regex_match(qsl("^[0-9]+$"), phone, {}).valid();
|
return qthelp::regex_match(u"^[0-9]+$"_q, phone, {}).valid();
|
||||||
};
|
};
|
||||||
if (domain == qsl("telegrampassport")) {
|
if (domain == u"telegrampassport"_q) {
|
||||||
return ShowPassportForm(controller, params);
|
return ShowPassportForm(controller, params);
|
||||||
} else if (!validDomain(domain) && !validPhone(phone)) {
|
} else if (!validDomain(domain) && !validPhone(phone)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -359,17 +359,17 @@ bool ResolveUsernameOrPhone(
|
||||||
|| resolveType == ResolveType::AddToChannel) {
|
|| resolveType == ResolveType::AddToChannel) {
|
||||||
adminRights = ParseRequestedAdminRights(params.value(u"admin"_q));
|
adminRights = ParseRequestedAdminRights(params.value(u"admin"_q));
|
||||||
}
|
}
|
||||||
const auto postParam = params.value(qsl("post"));
|
const auto postParam = params.value(u"post"_q);
|
||||||
if (const auto postId = postParam.toInt()) {
|
if (const auto postId = postParam.toInt()) {
|
||||||
post = postId;
|
post = postId;
|
||||||
}
|
}
|
||||||
const auto commentParam = params.value(qsl("comment"));
|
const auto commentParam = params.value(u"comment"_q);
|
||||||
const auto commentId = commentParam.toInt();
|
const auto commentId = commentParam.toInt();
|
||||||
const auto topicParam = params.value(qsl("topic"));
|
const auto topicParam = params.value(u"topic"_q);
|
||||||
const auto topicId = topicParam.toInt();
|
const auto topicId = topicParam.toInt();
|
||||||
const auto threadParam = params.value(qsl("thread"));
|
const auto threadParam = params.value(u"thread"_q);
|
||||||
const auto threadId = topicId ? topicId : threadParam.toInt();
|
const auto threadId = topicId ? topicId : threadParam.toInt();
|
||||||
const auto gameParam = params.value(qsl("game"));
|
const auto gameParam = params.value(u"game"_q);
|
||||||
if (!gameParam.isEmpty() && validDomain(gameParam)) {
|
if (!gameParam.isEmpty() && validDomain(gameParam)) {
|
||||||
startToken = gameParam;
|
startToken = gameParam;
|
||||||
resolveType = ResolveType::ShareGame;
|
resolveType = ResolveType::ShareGame;
|
||||||
|
@ -423,13 +423,13 @@ bool ResolvePrivatePost(
|
||||||
match->captured(1),
|
match->captured(1),
|
||||||
qthelp::UrlParamNameTransform::ToLower);
|
qthelp::UrlParamNameTransform::ToLower);
|
||||||
const auto channelId = ChannelId(
|
const auto channelId = ChannelId(
|
||||||
params.value(qsl("channel")).toULongLong());
|
params.value(u"channel"_q).toULongLong());
|
||||||
const auto msgId = params.value(qsl("post")).toInt();
|
const auto msgId = params.value(u"post"_q).toInt();
|
||||||
const auto commentParam = params.value(qsl("comment"));
|
const auto commentParam = params.value(u"comment"_q);
|
||||||
const auto commentId = commentParam.toInt();
|
const auto commentId = commentParam.toInt();
|
||||||
const auto topicParam = params.value(qsl("topic"));
|
const auto topicParam = params.value(u"topic"_q);
|
||||||
const auto topicId = topicParam.toInt();
|
const auto topicId = topicParam.toInt();
|
||||||
const auto threadParam = params.value(qsl("thread"));
|
const auto threadParam = params.value(u"thread"_q);
|
||||||
const auto threadId = topicId ? topicId : threadParam.toInt();
|
const auto threadId = topicId ? topicId : threadParam.toInt();
|
||||||
if (!channelId || (msgId && !IsServerMsgId(msgId))) {
|
if (!channelId || (msgId && !IsServerMsgId(msgId))) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -465,19 +465,19 @@ bool ResolveSettings(
|
||||||
const auto section = match->captured(1).mid(1).toLower();
|
const auto section = match->captured(1).mid(1).toLower();
|
||||||
|
|
||||||
const auto type = [&]() -> std::optional<::Settings::Type> {
|
const auto type = [&]() -> std::optional<::Settings::Type> {
|
||||||
if (section == qstr("language")) {
|
if (section == u"language"_q) {
|
||||||
ShowLanguagesBox();
|
ShowLanguagesBox();
|
||||||
return {};
|
return {};
|
||||||
} else if (section == qstr("devices")) {
|
} else if (section == u"devices"_q) {
|
||||||
controller->session().api().authorizations().reload();
|
controller->session().api().authorizations().reload();
|
||||||
return ::Settings::Sessions::Id();
|
return ::Settings::Sessions::Id();
|
||||||
} else if (section == qstr("folders")) {
|
} else if (section == u"folders"_q) {
|
||||||
return ::Settings::Folders::Id();
|
return ::Settings::Folders::Id();
|
||||||
} else if (section == qstr("privacy")) {
|
} else if (section == u"privacy"_q) {
|
||||||
return ::Settings::PrivacySecurity::Id();
|
return ::Settings::PrivacySecurity::Id();
|
||||||
} else if (section == qstr("themes")) {
|
} else if (section == u"themes"_q) {
|
||||||
return ::Settings::Chat::Id();
|
return ::Settings::Chat::Id();
|
||||||
} else if (section == qstr("change_number")) {
|
} else if (section == u"change_number"_q) {
|
||||||
return ::Settings::ChangePhone::Id();
|
return ::Settings::ChangePhone::Id();
|
||||||
}
|
}
|
||||||
return ::Settings::Main::Id();
|
return ::Settings::Main::Id();
|
||||||
|
@ -531,7 +531,7 @@ bool OpenMediaTimestamp(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto base = match->captured(1);
|
const auto base = match->captured(1);
|
||||||
if (base.startsWith(qstr("doc"))) {
|
if (base.startsWith(u"doc"_q)) {
|
||||||
const auto parts = base.mid(3).split('_');
|
const auto parts = base.mid(3).split('_');
|
||||||
const auto documentId = parts.value(0).toULongLong();
|
const auto documentId = parts.value(0).toULongLong();
|
||||||
const auto itemId = FullMsgId(
|
const auto itemId = FullMsgId(
|
||||||
|
@ -750,7 +750,7 @@ bool ResolveInvoice(
|
||||||
const auto params = url_parse_params(
|
const auto params = url_parse_params(
|
||||||
match->captured(1),
|
match->captured(1),
|
||||||
qthelp::UrlParamNameTransform::ToLower);
|
qthelp::UrlParamNameTransform::ToLower);
|
||||||
const auto slug = params.value(qsl("slug"));
|
const auto slug = params.value(u"slug"_q);
|
||||||
if (slug.isEmpty()) {
|
if (slug.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -772,7 +772,7 @@ bool ResolvePremiumOffer(
|
||||||
const auto params = url_parse_params(
|
const auto params = url_parse_params(
|
||||||
match->captured(1).mid(1),
|
match->captured(1).mid(1),
|
||||||
qthelp::UrlParamNameTransform::ToLower);
|
qthelp::UrlParamNameTransform::ToLower);
|
||||||
const auto refAddition = params.value(qsl("ref"));
|
const auto refAddition = params.value(u"ref"_q);
|
||||||
const auto ref = "deeplink"
|
const auto ref = "deeplink"
|
||||||
+ (refAddition.isEmpty() ? QString() : '_' + refAddition);
|
+ (refAddition.isEmpty() ? QString() : '_' + refAddition);
|
||||||
::Settings::ShowPremium(controller, ref);
|
::Settings::ShowPremium(controller, ref);
|
||||||
|
@ -785,75 +785,75 @@ bool ResolvePremiumOffer(
|
||||||
const std::vector<LocalUrlHandler> &LocalUrlHandlers() {
|
const std::vector<LocalUrlHandler> &LocalUrlHandlers() {
|
||||||
static auto Result = std::vector<LocalUrlHandler>{
|
static auto Result = std::vector<LocalUrlHandler>{
|
||||||
{
|
{
|
||||||
qsl("^join/?\\?invite=([a-zA-Z0-9\\.\\_\\-]+)(&|$)"),
|
u"^join/?\\?invite=([a-zA-Z0-9\\.\\_\\-]+)(&|$)"_q,
|
||||||
JoinGroupByHash
|
JoinGroupByHash
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
qsl("^(addstickers|addemoji)/?\\?set=([a-zA-Z0-9\\.\\_]+)(&|$)"),
|
u"^(addstickers|addemoji)/?\\?set=([a-zA-Z0-9\\.\\_]+)(&|$)"_q,
|
||||||
ShowStickerSet
|
ShowStickerSet
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
qsl("^addtheme/?\\?slug=([a-zA-Z0-9\\.\\_]+)(&|$)"),
|
u"^addtheme/?\\?slug=([a-zA-Z0-9\\.\\_]+)(&|$)"_q,
|
||||||
ShowTheme
|
ShowTheme
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
qsl("^setlanguage/?(\\?lang=([a-zA-Z0-9\\.\\_\\-]+))?(&|$)"),
|
u"^setlanguage/?(\\?lang=([a-zA-Z0-9\\.\\_\\-]+))?(&|$)"_q,
|
||||||
SetLanguage
|
SetLanguage
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
qsl("^msg_url/?\\?(.+)(#|$)"),
|
u"^msg_url/?\\?(.+)(#|$)"_q,
|
||||||
ShareUrl
|
ShareUrl
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
qsl("^confirmphone/?\\?(.+)(#|$)"),
|
u"^confirmphone/?\\?(.+)(#|$)"_q,
|
||||||
ConfirmPhone
|
ConfirmPhone
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
qsl("^share_game_score/?\\?(.+)(#|$)"),
|
u"^share_game_score/?\\?(.+)(#|$)"_q,
|
||||||
ShareGameScore
|
ShareGameScore
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
qsl("^socks/?\\?(.+)(#|$)"),
|
u"^socks/?\\?(.+)(#|$)"_q,
|
||||||
ApplySocksProxy
|
ApplySocksProxy
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
qsl("^proxy/?\\?(.+)(#|$)"),
|
u"^proxy/?\\?(.+)(#|$)"_q,
|
||||||
ApplyMtprotoProxy
|
ApplyMtprotoProxy
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
qsl("^passport/?\\?(.+)(#|$)"),
|
u"^passport/?\\?(.+)(#|$)"_q,
|
||||||
ShowPassport
|
ShowPassport
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
qsl("^bg/?\\?(.+)(#|$)"),
|
u"^bg/?\\?(.+)(#|$)"_q,
|
||||||
ShowWallPaper
|
ShowWallPaper
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
qsl("^resolve/?\\?(.+)(#|$)"),
|
u"^resolve/?\\?(.+)(#|$)"_q,
|
||||||
ResolveUsernameOrPhone
|
ResolveUsernameOrPhone
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
qsl("^privatepost/?\\?(.+)(#|$)"),
|
u"^privatepost/?\\?(.+)(#|$)"_q,
|
||||||
ResolvePrivatePost
|
ResolvePrivatePost
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
qsl("^settings(/language|/devices|/folders|/privacy|/themes|/change_number)?$"),
|
u"^settings(/language|/devices|/folders|/privacy|/themes|/change_number)?$"_q,
|
||||||
ResolveSettings
|
ResolveSettings
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
qsl("^test_chat_theme/?\\?(.+)(#|$)"),
|
u"^test_chat_theme/?\\?(.+)(#|$)"_q,
|
||||||
ResolveTestChatTheme,
|
ResolveTestChatTheme,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
qsl("invoice/?\\?(.+)(#|$)"),
|
u"invoice/?\\?(.+)(#|$)"_q,
|
||||||
ResolveInvoice,
|
ResolveInvoice,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
qsl("premium_offer/?(\\?.+)?(#|$)"),
|
u"premium_offer/?(\\?.+)?(#|$)"_q,
|
||||||
ResolvePremiumOffer,
|
ResolvePremiumOffer,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
qsl("^([^\\?]+)(\\?|#|$)"),
|
u"^([^\\?]+)(\\?|#|$)"_q,
|
||||||
HandleUnknown
|
HandleUnknown
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -863,15 +863,15 @@ const std::vector<LocalUrlHandler> &LocalUrlHandlers() {
|
||||||
const std::vector<LocalUrlHandler> &InternalUrlHandlers() {
|
const std::vector<LocalUrlHandler> &InternalUrlHandlers() {
|
||||||
static auto Result = std::vector<LocalUrlHandler>{
|
static auto Result = std::vector<LocalUrlHandler>{
|
||||||
{
|
{
|
||||||
qsl("^media_timestamp/?\\?base=([a-zA-Z0-9\\.\\_\\-]+)&t=(\\d+)(&|$)"),
|
u"^media_timestamp/?\\?base=([a-zA-Z0-9\\.\\_\\-]+)&t=(\\d+)(&|$)"_q,
|
||||||
OpenMediaTimestamp
|
OpenMediaTimestamp
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
qsl("^show_invite_link/?\\?link=([a-zA-Z0-9_\\+\\/\\=\\-]+)(&|$)"),
|
u"^show_invite_link/?\\?link=([a-zA-Z0-9_\\+\\/\\=\\-]+)(&|$)"_q,
|
||||||
ShowInviteLink
|
ShowInviteLink
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
qsl("^url:(.+)$"),
|
u"^url:(.+)$"_q,
|
||||||
OpenExternalLink
|
OpenExternalLink
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -885,7 +885,7 @@ QString TryConvertUrlToLocal(QString url) {
|
||||||
|
|
||||||
using namespace qthelp;
|
using namespace qthelp;
|
||||||
auto matchOptions = RegExOption::CaseInsensitive;
|
auto matchOptions = RegExOption::CaseInsensitive;
|
||||||
auto subdomainMatch = regex_match(qsl("^(https?://)?([a-zA-Z0-9\\_]+)\\.t\\.me(/\\d+)?/?(\\?.+)?"), url, matchOptions);
|
auto subdomainMatch = regex_match(u"^(https?://)?([a-zA-Z0-9\\_]+)\\.t\\.me(/\\d+)?/?(\\?.+)?"_q, url, matchOptions);
|
||||||
if (subdomainMatch) {
|
if (subdomainMatch) {
|
||||||
const auto name = subdomainMatch->captured(2);
|
const auto name = subdomainMatch->captured(2);
|
||||||
if (name.size() > 1 && name != "www") {
|
if (name.size() > 1 && name != "www") {
|
||||||
|
@ -900,65 +900,85 @@ QString TryConvertUrlToLocal(QString url) {
|
||||||
: url;
|
: url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto telegramMeMatch = regex_match(qsl("^(https?://)?(www\\.)?(telegram\\.(me|dog)|t\\.me)/(.+)$"), url, matchOptions);
|
auto telegramMeMatch = regex_match(u"^(https?://)?(www\\.)?(telegram\\.(me|dog)|t\\.me)/(.+)$"_q, url, matchOptions);
|
||||||
if (telegramMeMatch) {
|
if (telegramMeMatch) {
|
||||||
auto query = telegramMeMatch->capturedView(5);
|
const auto query = telegramMeMatch->capturedView(5);
|
||||||
if (auto phoneMatch = regex_match(qsl("^\\+([0-9]+)(\\?|$)"), query, matchOptions)) {
|
if (const auto phoneMatch = regex_match(u"^\\+([0-9]+)(\\?|$)"_q, query, matchOptions)) {
|
||||||
auto params = query.mid(phoneMatch->captured(0).size()).toString();
|
const auto params = query.mid(phoneMatch->captured(0).size()).toString();
|
||||||
return qsl("tg://resolve?phone=") + phoneMatch->captured(1) + (params.isEmpty() ? QString() : '&' + params);
|
return u"tg://resolve?phone="_q + phoneMatch->captured(1) + (params.isEmpty() ? QString() : '&' + params);
|
||||||
} else if (auto joinChatMatch = regex_match(qsl("^(joinchat/|\\+|\\%20)([a-zA-Z0-9\\.\\_\\-]+)(\\?|$)"), query, matchOptions)) {
|
} else if (const auto joinChatMatch = regex_match(u"^(joinchat/|\\+|\\%20)([a-zA-Z0-9\\.\\_\\-]+)(\\?|$)"_q, query, matchOptions)) {
|
||||||
return qsl("tg://join?invite=") + url_encode(joinChatMatch->captured(2));
|
return u"tg://join?invite="_q + url_encode(joinChatMatch->captured(2));
|
||||||
} else if (auto stickerSetMatch = regex_match(qsl("^(addstickers|addemoji)/([a-zA-Z0-9\\.\\_]+)(\\?|$)"), query, matchOptions)) {
|
} else if (const auto stickerSetMatch = regex_match(u"^(addstickers|addemoji)/([a-zA-Z0-9\\.\\_]+)(\\?|$)"_q, query, matchOptions)) {
|
||||||
return qsl("tg://") + stickerSetMatch->captured(1) + "?set=" + url_encode(stickerSetMatch->captured(2));
|
return u"tg://"_q + stickerSetMatch->captured(1) + "?set=" + url_encode(stickerSetMatch->captured(2));
|
||||||
} else if (auto themeMatch = regex_match(qsl("^addtheme/([a-zA-Z0-9\\.\\_]+)(\\?|$)"), query, matchOptions)) {
|
} else if (const auto themeMatch = regex_match(u"^addtheme/([a-zA-Z0-9\\.\\_]+)(\\?|$)"_q, query, matchOptions)) {
|
||||||
return qsl("tg://addtheme?slug=") + url_encode(themeMatch->captured(1));
|
return u"tg://addtheme?slug="_q + url_encode(themeMatch->captured(1));
|
||||||
} else if (auto languageMatch = regex_match(qsl("^setlanguage/([a-zA-Z0-9\\.\\_\\-]+)(\\?|$)"), query, matchOptions)) {
|
} else if (const auto languageMatch = regex_match(u"^setlanguage/([a-zA-Z0-9\\.\\_\\-]+)(\\?|$)"_q, query, matchOptions)) {
|
||||||
return qsl("tg://setlanguage?lang=") + url_encode(languageMatch->captured(1));
|
return u"tg://setlanguage?lang="_q + url_encode(languageMatch->captured(1));
|
||||||
} else if (auto shareUrlMatch = regex_match(qsl("^share/url/?\\?(.+)$"), query, matchOptions)) {
|
} else if (const auto shareUrlMatch = regex_match(u"^share/url/?\\?(.+)$"_q, query, matchOptions)) {
|
||||||
return qsl("tg://msg_url?") + shareUrlMatch->captured(1);
|
return u"tg://msg_url?"_q + shareUrlMatch->captured(1);
|
||||||
} else if (auto confirmPhoneMatch = regex_match(qsl("^confirmphone/?\\?(.+)"), query, matchOptions)) {
|
} else if (const auto confirmPhoneMatch = regex_match(u"^confirmphone/?\\?(.+)"_q, query, matchOptions)) {
|
||||||
return qsl("tg://confirmphone?") + confirmPhoneMatch->captured(1);
|
return u"tg://confirmphone?"_q + confirmPhoneMatch->captured(1);
|
||||||
} else if (auto ivMatch = regex_match(qsl("^iv/?\\?(.+)(#|$)"), query, matchOptions)) {
|
} else if (const auto ivMatch = regex_match(u"^iv/?\\?(.+)(#|$)"_q, query, matchOptions)) {
|
||||||
//
|
//
|
||||||
// We need to show our t.me page, not the url directly.
|
// We need to show our t.me page, not the url directly.
|
||||||
//
|
//
|
||||||
//auto params = url_parse_params(ivMatch->captured(1), UrlParamNameTransform::ToLower);
|
//auto params = url_parse_params(ivMatch->captured(1), UrlParamNameTransform::ToLower);
|
||||||
//auto previewedUrl = params.value(qsl("url"));
|
//auto previewedUrl = params.value(u"url"_q);
|
||||||
//if (previewedUrl.startsWith(qstr("http://"), Qt::CaseInsensitive)
|
//if (previewedUrl.startsWith(u"http://"_q, Qt::CaseInsensitive)
|
||||||
// || previewedUrl.startsWith(qstr("https://"), Qt::CaseInsensitive)) {
|
// || previewedUrl.startsWith(u"https://"_q, Qt::CaseInsensitive)) {
|
||||||
// return previewedUrl;
|
// return previewedUrl;
|
||||||
//}
|
//}
|
||||||
return url;
|
return url;
|
||||||
} else if (auto socksMatch = regex_match(qsl("^socks/?\\?(.+)(#|$)"), query, matchOptions)) {
|
} else if (const auto socksMatch = regex_match(u"^socks/?\\?(.+)(#|$)"_q, query, matchOptions)) {
|
||||||
return qsl("tg://socks?") + socksMatch->captured(1);
|
return u"tg://socks?"_q + socksMatch->captured(1);
|
||||||
} else if (auto proxyMatch = regex_match(qsl("^proxy/?\\?(.+)(#|$)"), query, matchOptions)) {
|
} else if (const auto proxyMatch = regex_match(u"^proxy/?\\?(.+)(#|$)"_q, query, matchOptions)) {
|
||||||
return qsl("tg://proxy?") + proxyMatch->captured(1);
|
return u"tg://proxy?"_q + proxyMatch->captured(1);
|
||||||
} else if (auto invoiceMatch = regex_match(qsl("^(invoice/|\\$)([a-zA-Z0-9_\\-]+)(\\?|#|$)"), query, matchOptions)) {
|
} else if (const auto invoiceMatch = regex_match(u"^(invoice/|\\$)([a-zA-Z0-9_\\-]+)(\\?|#|$)"_q, query, matchOptions)) {
|
||||||
return qsl("tg://invoice?slug=") + invoiceMatch->captured(2);
|
return u"tg://invoice?slug="_q + invoiceMatch->captured(2);
|
||||||
} else if (auto bgMatch = regex_match(qsl("^bg/([a-zA-Z0-9\\.\\_\\-\\~]+)(\\?(.+)?)?$"), query, matchOptions)) {
|
} else if (const auto bgMatch = regex_match(u"^bg/([a-zA-Z0-9\\.\\_\\-\\~]+)(\\?(.+)?)?$"_q, query, matchOptions)) {
|
||||||
const auto params = bgMatch->captured(3);
|
const auto params = bgMatch->captured(3);
|
||||||
const auto bg = bgMatch->captured(1);
|
const auto bg = bgMatch->captured(1);
|
||||||
const auto type = regex_match(qsl("^[a-fA-F0-9]{6}^"), bg)
|
const auto type = regex_match(u"^[a-fA-F0-9]{6}^"_q, bg)
|
||||||
? "color"
|
? "color"
|
||||||
: (regex_match(qsl("^[a-fA-F0-9]{6}\\-[a-fA-F0-9]{6}$"), bg)
|
: (regex_match(u"^[a-fA-F0-9]{6}\\-[a-fA-F0-9]{6}$"_q, bg)
|
||||||
|| regex_match(qsl("^[a-fA-F0-9]{6}(\\~[a-fA-F0-9]{6}){1,3}$"), bg))
|
|| regex_match(u"^[a-fA-F0-9]{6}(\\~[a-fA-F0-9]{6}){1,3}$"_q, bg))
|
||||||
? "gradient"
|
? "gradient"
|
||||||
: "slug";
|
: "slug";
|
||||||
return qsl("tg://bg?") + type + '=' + bg + (params.isEmpty() ? QString() : '&' + params);
|
return u"tg://bg?"_q + type + '=' + bg + (params.isEmpty() ? QString() : '&' + params);
|
||||||
} else if (auto postMatch = regex_match(qsl("^c/(\\-?\\d+)(/\\d+)?(/?\\?|/?$)"), query, matchOptions)) {
|
} else if (const auto privateMatch = regex_match(u"^"
|
||||||
const auto params = query.mid(postMatch->captured(0).size()).toString();
|
"c/(\\-?\\d+)"
|
||||||
const auto base = u"tg://privatepost?channel="_q + postMatch->captured(1);
|
"("
|
||||||
const auto post = postMatch->captured(2).mid(1);
|
"/?\\?|"
|
||||||
return base
|
"/?$|"
|
||||||
+ (post.isEmpty() ? QString() : u"&post="_q + post)
|
"/\\d+/?(\\?|$)|"
|
||||||
+ (params.isEmpty() ? QString() : '&' + params);
|
"/\\d+/\\d+/?(\\?|$)"
|
||||||
} else if (auto usernameMatch = regex_match(qsl("^([a-zA-Z0-9\\.\\_]+)(/?\\?|/?$|/(\\d+)/?(?:\\?|$))"), query, matchOptions)) {
|
")"_q, query, matchOptions)) {
|
||||||
auto params = query.mid(usernameMatch->captured(0).size()).toString();
|
const auto params = query.mid(privateMatch->captured(0).size()).toString();
|
||||||
auto postParam = QString();
|
const auto base = u"tg://privatepost?channel="_q + privateMatch->captured(1);
|
||||||
if (auto postMatch = regex_match(qsl("^/\\d+/?(?:\\?|$)"), usernameMatch->captured(2))) {
|
auto added = QString();
|
||||||
postParam = qsl("&post=") + usernameMatch->captured(3);
|
if (const auto threadPostMatch = regex_match(u"^/(\\d+)/(\\d+)(/?\\?|/?$)"_q, privateMatch->captured(2))) {
|
||||||
|
added = u"&topic=%1&post=%2"_q.arg(threadPostMatch->captured(1)).arg(threadPostMatch->captured(2));
|
||||||
|
} else if (const auto postMatch = regex_match(u"^/(\\d+)(/?\\?|/?$)"_q, privateMatch->captured(2))) {
|
||||||
|
added = u"&post="_q + postMatch->captured(1);
|
||||||
}
|
}
|
||||||
return qsl("tg://resolve?domain=") + url_encode(usernameMatch->captured(1)) + postParam + (params.isEmpty() ? QString() : '&' + params);
|
return base + added + (params.isEmpty() ? QString() : '&' + params);
|
||||||
|
} else if (const auto usernameMatch = regex_match(u"^"
|
||||||
|
"([a-zA-Z0-9\\.\\_]+)"
|
||||||
|
"("
|
||||||
|
"/?\\?|"
|
||||||
|
"/?$|"
|
||||||
|
"/\\d+/?(\\?|$)|"
|
||||||
|
"/\\d+/\\d+/?(\\?|$)"
|
||||||
|
")"_q, query, matchOptions)) {
|
||||||
|
const auto params = query.mid(usernameMatch->captured(0).size()).toString();
|
||||||
|
const auto base = u"tg://resolve?domain="_q + url_encode(usernameMatch->captured(1));
|
||||||
|
auto added = QString();
|
||||||
|
if (const auto threadPostMatch = regex_match(u"^/(\\d+)/(\\d+)(/?\\?|/?$)"_q, usernameMatch->captured(2))) {
|
||||||
|
added = u"&topic=%1&post=%2"_q.arg(threadPostMatch->captured(1)).arg(threadPostMatch->captured(2));
|
||||||
|
} else if (const auto postMatch = regex_match(u"^/(\\d+)(/?\\?|/?$)"_q, usernameMatch->captured(2))) {
|
||||||
|
added = u"&post="_q + postMatch->captured(1);
|
||||||
|
}
|
||||||
|
return base + added + (params.isEmpty() ? QString() : '&' + params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return url;
|
return url;
|
||||||
|
@ -966,27 +986,27 @@ QString TryConvertUrlToLocal(QString url) {
|
||||||
|
|
||||||
bool InternalPassportLink(const QString &url) {
|
bool InternalPassportLink(const QString &url) {
|
||||||
const auto urlTrimmed = url.trimmed();
|
const auto urlTrimmed = url.trimmed();
|
||||||
if (!urlTrimmed.startsWith(qstr("tg://"), Qt::CaseInsensitive)) {
|
if (!urlTrimmed.startsWith(u"tg://"_q, Qt::CaseInsensitive)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto command = base::StringViewMid(urlTrimmed, qstr("tg://").size());
|
const auto command = base::StringViewMid(urlTrimmed, u"tg://"_q.size());
|
||||||
|
|
||||||
using namespace qthelp;
|
using namespace qthelp;
|
||||||
const auto matchOptions = RegExOption::CaseInsensitive;
|
const auto matchOptions = RegExOption::CaseInsensitive;
|
||||||
const auto authMatch = regex_match(
|
const auto authMatch = regex_match(
|
||||||
qsl("^passport/?\\?(.+)(#|$)"),
|
u"^passport/?\\?(.+)(#|$)"_q,
|
||||||
command,
|
command,
|
||||||
matchOptions);
|
matchOptions);
|
||||||
const auto usernameMatch = regex_match(
|
const auto usernameMatch = regex_match(
|
||||||
qsl("^resolve/?\\?(.+)(#|$)"),
|
u"^resolve/?\\?(.+)(#|$)"_q,
|
||||||
command,
|
command,
|
||||||
matchOptions);
|
matchOptions);
|
||||||
const auto usernameValue = usernameMatch->hasMatch()
|
const auto usernameValue = usernameMatch->hasMatch()
|
||||||
? url_parse_params(
|
? url_parse_params(
|
||||||
usernameMatch->captured(1),
|
usernameMatch->captured(1),
|
||||||
UrlParamNameTransform::ToLower).value(qsl("domain"))
|
UrlParamNameTransform::ToLower).value(u"domain"_q)
|
||||||
: QString();
|
: QString();
|
||||||
const auto authLegacy = (usernameValue == qstr("telegrampassport"));
|
const auto authLegacy = (usernameValue == u"telegrampassport"_q);
|
||||||
return authMatch->hasMatch() || authLegacy;
|
return authMatch->hasMatch() || authLegacy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -540,7 +540,7 @@ void DownloadManager::loadingStopWithConfirmation(
|
||||||
if (const auto strong = weak.get()) {
|
if (const auto strong = weak.get()) {
|
||||||
if (const auto item = strong->data().message(id)) {
|
if (const auto item = strong->data().message(id)) {
|
||||||
if (const auto window = strong->tryResolveWindow()) {
|
if (const auto window = strong->tryResolveWindow()) {
|
||||||
window->showPeerHistoryAtItem(item);
|
window->showMessage(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -542,7 +542,7 @@ void Widget::setupDownloadBar() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (first) {
|
if (first) {
|
||||||
controller()->showPeerHistoryAtItem(first);
|
controller()->showMessage(first);
|
||||||
}
|
}
|
||||||
}, _downloadBar->lifetime());
|
}, _downloadBar->lifetime());
|
||||||
|
|
||||||
|
|
|
@ -641,7 +641,7 @@ TextWithEntities GenerateDefaultBannedRightsChangeText(
|
||||||
result.append(qs(data.vtitle()));
|
result.append(qs(data.vtitle()));
|
||||||
return Ui::Text::Link(
|
return Ui::Text::Link(
|
||||||
std::move(result),
|
std::move(result),
|
||||||
u"internal:url:https://t.me/c/%1?topic=%2"_q.arg(
|
u"internal:url:https://t.me/c/%1/%2"_q.arg(
|
||||||
peerToChannel(channel->id).bare).arg(
|
peerToChannel(channel->id).bare).arg(
|
||||||
data.vid().v));
|
data.vid().v));
|
||||||
}, [](const MTPDforumTopicDeleted &) {
|
}, [](const MTPDforumTopicDeleted &) {
|
||||||
|
|
|
@ -1436,9 +1436,8 @@ ClickHandlerPtr goToMessageClickHandler(
|
||||||
params.origin = Window::SectionShow::OriginMessage{
|
params.origin = Window::SectionShow::OriginMessage{
|
||||||
returnToId
|
returnToId
|
||||||
};
|
};
|
||||||
const auto item = peer->owner().message(peer, msgId);
|
if (const auto item = peer->owner().message(peer, msgId)) {
|
||||||
if (const auto topic = item ? item->topic() : nullptr) {
|
controller->showMessage(item);
|
||||||
controller->showTopic(topic, msgId, params);
|
|
||||||
} else {
|
} else {
|
||||||
controller->showPeerHistory(peer, params, msgId);
|
controller->showPeerHistory(peer, params, msgId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -609,8 +609,8 @@ HistoryWidget::HistoryWidget(
|
||||||
) | rpl::start_with_next([=](const Data::EntryUpdate &update) {
|
) | rpl::start_with_next([=](const Data::EntryUpdate &update) {
|
||||||
if (_pinnedTracker
|
if (_pinnedTracker
|
||||||
&& (update.flags & EntryUpdateFlag::HasPinnedMessages)
|
&& (update.flags & EntryUpdateFlag::HasPinnedMessages)
|
||||||
&& (_migrated && update.entry.get() == _migrated)
|
&& ((update.entry.get() == _history)
|
||||||
|| (update.entry.get() == _history)) {
|
|| (update.entry.get() == _migrated))) {
|
||||||
checkPinnedBarState();
|
checkPinnedBarState();
|
||||||
}
|
}
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
@ -6022,7 +6022,7 @@ void HistoryWidget::handlePeerMigration() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryWidget::replyToPreviousMessage() {
|
bool HistoryWidget::replyToPreviousMessage() {
|
||||||
if (!_history || _editMsgId) {
|
if (!_history || _editMsgId || _history->peer->isForum()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto fullId = FullMsgId(_history->peer->id, _replyToId);
|
const auto fullId = FullMsgId(_history->peer->id, _replyToId);
|
||||||
|
@ -6030,14 +6030,14 @@ bool HistoryWidget::replyToPreviousMessage() {
|
||||||
if (const auto view = item->mainView()) {
|
if (const auto view = item->mainView()) {
|
||||||
if (const auto previousView = view->previousDisplayedInBlocks()) {
|
if (const auto previousView = view->previousDisplayedInBlocks()) {
|
||||||
const auto previous = previousView->data();
|
const auto previous = previousView->data();
|
||||||
controller()->showPeerHistoryAtItem(previous);
|
controller()->showMessage(previous);
|
||||||
replyToMessage(previous);
|
replyToMessage(previous);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (const auto previousView = _history->findLastDisplayed()) {
|
} else if (const auto previousView = _history->findLastDisplayed()) {
|
||||||
const auto previous = previousView->data();
|
const auto previous = previousView->data();
|
||||||
controller()->showPeerHistoryAtItem(previous);
|
controller()->showMessage(previous);
|
||||||
replyToMessage(previous);
|
replyToMessage(previous);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -6045,7 +6045,7 @@ bool HistoryWidget::replyToPreviousMessage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryWidget::replyToNextMessage() {
|
bool HistoryWidget::replyToNextMessage() {
|
||||||
if (!_history || _editMsgId) {
|
if (!_history || _editMsgId || _history->peer->isForum()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto fullId = FullMsgId(_history->peer->id, _replyToId);
|
const auto fullId = FullMsgId(_history->peer->id, _replyToId);
|
||||||
|
@ -6053,7 +6053,7 @@ bool HistoryWidget::replyToNextMessage() {
|
||||||
if (const auto view = item->mainView()) {
|
if (const auto view = item->mainView()) {
|
||||||
if (const auto nextView = view->nextDisplayedInBlocks()) {
|
if (const auto nextView = view->nextDisplayedInBlocks()) {
|
||||||
const auto next = nextView->data();
|
const auto next = nextView->data();
|
||||||
controller()->showPeerHistoryAtItem(next);
|
controller()->showMessage(next);
|
||||||
replyToMessage(next);
|
replyToMessage(next);
|
||||||
} else {
|
} else {
|
||||||
_highlighter.clear();
|
_highlighter.clear();
|
||||||
|
|
|
@ -720,9 +720,8 @@ bool AddGoToMessageAction(
|
||||||
const auto itemId = view->data()->fullId();
|
const auto itemId = view->data()->fullId();
|
||||||
const auto controller = list->controller();
|
const auto controller = list->controller();
|
||||||
menu->addAction(tr::lng_context_to_msg(tr::now), crl::guard(controller, [=] {
|
menu->addAction(tr::lng_context_to_msg(tr::now), crl::guard(controller, [=] {
|
||||||
const auto item = controller->session().data().message(itemId);
|
if (const auto item = controller->session().data().message(itemId)) {
|
||||||
if (item) {
|
controller->showMessage(item);
|
||||||
goToMessageClickHandler(item)->onClick(ClickContext{});
|
|
||||||
}
|
}
|
||||||
}), &st::menuIconShowInChat);
|
}), &st::menuIconShowInChat);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -692,7 +692,7 @@ auto Element::contextDependentServiceText() -> TextWithLinks {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
const auto topicUrl = u"internal:url:https://t.me/c/%1?topic=%2"_q
|
const auto topicUrl = u"internal:url:https://t.me/c/%1/%2"_q
|
||||||
.arg(peerToChannel(peerId).bare)
|
.arg(peerToChannel(peerId).bare)
|
||||||
.arg(topicRootId.bare);
|
.arg(topicRootId.bare);
|
||||||
const auto fromLink = [&](int index) {
|
const auto fromLink = [&](int index) {
|
||||||
|
|
|
@ -73,7 +73,7 @@ bool LayerWidget::floatPlayerIsVisible(not_null<HistoryItem*> item) {
|
||||||
|
|
||||||
void LayerWidget::floatPlayerDoubleClickEvent(
|
void LayerWidget::floatPlayerDoubleClickEvent(
|
||||||
not_null<const HistoryItem*> item) {
|
not_null<const HistoryItem*> item) {
|
||||||
_controller->showPeerHistoryAtItem(item);
|
_controller->showMessage(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerWidget::setupHeightConsumers() {
|
void LayerWidget::setupHeightConsumers() {
|
||||||
|
|
|
@ -412,7 +412,7 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
||||||
} else {
|
} else {
|
||||||
const auto topicRootId = _topic ? _topic->rootId() : 0;
|
const auto topicRootId = _topic ? _topic->rootId() : 0;
|
||||||
const auto addToLink = topicRootId
|
const auto addToLink = topicRootId
|
||||||
? "?topic=" + QString::number(topicRootId.bare)
|
? ('/' + QString::number(topicRootId.bare))
|
||||||
: QString();
|
: QString();
|
||||||
auto linkText = LinkValue(
|
auto linkText = LinkValue(
|
||||||
_peer,
|
_peer,
|
||||||
|
|
|
@ -196,7 +196,7 @@ void Widget::floatPlayerDoubleClickEvent(not_null<const HistoryItem*> item) {
|
||||||
&item->history()->peer->session().account(),
|
&item->history()->peer->session().account(),
|
||||||
item->history()->peer,
|
item->history()->peer,
|
||||||
[&](not_null<Window::SessionController*> controller) {
|
[&](not_null<Window::SessionController*> controller) {
|
||||||
controller->showPeerHistoryAtItem(item);
|
controller->showMessage(item);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -440,7 +440,7 @@ void Session::uploadsStopWithConfirmation(Fn<void()> done) {
|
||||||
|
|
||||||
if (const auto item = data().message(id)) {
|
if (const auto item = data().message(id)) {
|
||||||
if (const auto window = tryResolveWindow()) {
|
if (const auto window = tryResolveWindow()) {
|
||||||
window->showPeerHistoryAtItem(item);
|
window->showMessage(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -512,7 +512,7 @@ void MainWidget::floatPlayerClosed(FullMsgId itemId) {
|
||||||
|
|
||||||
void MainWidget::floatPlayerDoubleClickEvent(
|
void MainWidget::floatPlayerDoubleClickEvent(
|
||||||
not_null<const HistoryItem*> item) {
|
not_null<const HistoryItem*> item) {
|
||||||
_controller->showPeerHistoryAtItem(item);
|
_controller->showMessage(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWidget::setForwardDraft(PeerId peerId, Data::ForwardDraft &&draft) {
|
bool MainWidget::setForwardDraft(PeerId peerId, Data::ForwardDraft &&draft) {
|
||||||
|
@ -874,7 +874,7 @@ void MainWidget::createPlayer() {
|
||||||
_player->entity()->setCloseCallback([=] { closeBothPlayers(); });
|
_player->entity()->setCloseCallback([=] { closeBothPlayers(); });
|
||||||
_player->entity()->setShowItemCallback([=](
|
_player->entity()->setShowItemCallback([=](
|
||||||
not_null<const HistoryItem*> item) {
|
not_null<const HistoryItem*> item) {
|
||||||
_controller->showPeerHistoryAtItem(item);
|
_controller->showMessage(item);
|
||||||
});
|
});
|
||||||
|
|
||||||
_player->entity()->togglePlaylistRequests(
|
_player->entity()->togglePlaylistRequests(
|
||||||
|
|
|
@ -1585,7 +1585,7 @@ void OverlayWidget::toMessage() {
|
||||||
if (const auto item = _message) {
|
if (const auto item = _message) {
|
||||||
close();
|
close();
|
||||||
if (const auto window = findWindow()) {
|
if (const auto window = findWindow()) {
|
||||||
window->showPeerHistoryAtItem(item);
|
window->showMessage(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -314,6 +314,25 @@ void SessionNavigation::resolveChannelById(
|
||||||
}).fail(fail).send();
|
}).fail(fail).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SessionNavigation::showMessageByLinkResolved(
|
||||||
|
not_null<HistoryItem*> item,
|
||||||
|
const PeerByLinkInfo &info) {
|
||||||
|
auto params = SectionShow{
|
||||||
|
SectionShow::Way::Forward
|
||||||
|
};
|
||||||
|
params.origin = SectionShow::OriginMessage{
|
||||||
|
info.clickFromMessageId
|
||||||
|
};
|
||||||
|
const auto peer = item->history()->peer;
|
||||||
|
const auto topicId = peer->isForum() ? item->topicRootId() : 0;
|
||||||
|
if (topicId) {
|
||||||
|
const auto messageId = (item->id == topicId) ? MsgId() : item->id;
|
||||||
|
showRepliesForMessage(item->history(), topicId, messageId, params);
|
||||||
|
} else {
|
||||||
|
showPeerHistory(peer, params, item->id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SessionNavigation::showPeerByLinkResolved(
|
void SessionNavigation::showPeerByLinkResolved(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const PeerByLinkInfo &info) {
|
const PeerByLinkInfo &info) {
|
||||||
|
@ -326,7 +345,7 @@ void SessionNavigation::showPeerByLinkResolved(
|
||||||
if (info.voicechatHash && peer->isChannel()) {
|
if (info.voicechatHash && peer->isChannel()) {
|
||||||
// First show the channel itself.
|
// First show the channel itself.
|
||||||
crl::on_main(this, [=] {
|
crl::on_main(this, [=] {
|
||||||
showPeerHistory(peer->id, params, ShowAtUnreadMsgId);
|
showPeerHistory(peer, params, ShowAtUnreadMsgId);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Then try to join the voice chat.
|
// Then try to join the voice chat.
|
||||||
|
@ -350,7 +369,24 @@ void SessionNavigation::showPeerByLinkResolved(
|
||||||
commentId->id,
|
commentId->id,
|
||||||
params);
|
params);
|
||||||
} else if (peer->isForum()) {
|
} else if (peer->isForum()) {
|
||||||
parentController()->openForum(peer->asChannel(), params);
|
const auto itemId = info.messageId;
|
||||||
|
if (!itemId) {
|
||||||
|
parentController()->openForum(peer->asChannel(), params);
|
||||||
|
} else if (const auto item = peer->owner().message(peer, itemId)) {
|
||||||
|
showMessageByLinkResolved(item, info);
|
||||||
|
} else {
|
||||||
|
const auto callback = crl::guard(this, [=] {
|
||||||
|
if (const auto item = peer->owner().message(peer, itemId)) {
|
||||||
|
showMessageByLinkResolved(item, info);
|
||||||
|
} else {
|
||||||
|
showPeerHistory(peer, params, itemId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
peer->session().api().requestMessageData(
|
||||||
|
peer,
|
||||||
|
info.messageId,
|
||||||
|
callback);
|
||||||
|
}
|
||||||
} else if (bot
|
} else if (bot
|
||||||
&& (info.resolveType == ResolveType::AddToGroup
|
&& (info.resolveType == ResolveType::AddToGroup
|
||||||
|| info.resolveType == ResolveType::AddToChannel
|
|| info.resolveType == ResolveType::AddToChannel
|
||||||
|
@ -373,7 +409,7 @@ void SessionNavigation::showPeerByLinkResolved(
|
||||||
} else if (info.resolveType == ResolveType::Mention) {
|
} else if (info.resolveType == ResolveType::Mention) {
|
||||||
if (bot || peer->isChannel()) {
|
if (bot || peer->isChannel()) {
|
||||||
crl::on_main(this, [=] {
|
crl::on_main(this, [=] {
|
||||||
showPeerHistory(peer->id, params);
|
showPeerHistory(peer, params);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
showPeerInfo(peer, params);
|
showPeerInfo(peer, params);
|
||||||
|
@ -421,7 +457,7 @@ void SessionNavigation::showPeerByLinkResolved(
|
||||||
info.attachBotChooseTypes);
|
info.attachBotChooseTypes);
|
||||||
} else {
|
} else {
|
||||||
crl::on_main(this, [=] {
|
crl::on_main(this, [=] {
|
||||||
showPeerHistory(peer->id, params, msgId);
|
showPeerHistory(peer, params, msgId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1619,7 +1655,7 @@ void SessionController::showPeerHistory(
|
||||||
content()->ui_showPeerHistory(peerId, params, msgId);
|
content()->ui_showPeerHistory(peerId, params, msgId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionController::showPeerHistoryAtItem(
|
void SessionController::showMessage(
|
||||||
not_null<const HistoryItem*> item) {
|
not_null<const HistoryItem*> item) {
|
||||||
_window->invokeForSessionController(
|
_window->invokeForSessionController(
|
||||||
&item->history()->peer->session().account(),
|
&item->history()->peer->session().account(),
|
||||||
|
@ -1628,7 +1664,13 @@ void SessionController::showPeerHistoryAtItem(
|
||||||
if (item->isScheduled()) {
|
if (item->isScheduled()) {
|
||||||
controller->showSection(
|
controller->showSection(
|
||||||
std::make_shared<HistoryView::ScheduledMemento>(
|
std::make_shared<HistoryView::ScheduledMemento>(
|
||||||
item->history()));
|
item->history()),
|
||||||
|
SectionShow::Way::ClearStack);
|
||||||
|
} else if (const auto topic = item->topic()) {
|
||||||
|
controller->showTopic(
|
||||||
|
topic,
|
||||||
|
item->id,
|
||||||
|
SectionShow::Way::ClearStack);
|
||||||
} else {
|
} else {
|
||||||
controller->showPeerHistory(
|
controller->showPeerHistory(
|
||||||
item->history()->peer,
|
item->history()->peer,
|
||||||
|
|
|
@ -275,6 +275,9 @@ private:
|
||||||
const MTPcontacts_ResolvedPeer &result,
|
const MTPcontacts_ResolvedPeer &result,
|
||||||
Fn<void(not_null<PeerData*>)> done);
|
Fn<void(not_null<PeerData*>)> done);
|
||||||
|
|
||||||
|
void showMessageByLinkResolved(
|
||||||
|
not_null<HistoryItem*> item,
|
||||||
|
const PeerByLinkInfo &info);
|
||||||
void showPeerByLinkResolved(
|
void showPeerByLinkResolved(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const PeerByLinkInfo &info);
|
const PeerByLinkInfo &info);
|
||||||
|
@ -424,7 +427,7 @@ public:
|
||||||
const SectionShow ¶ms = SectionShow::Way::ClearStack,
|
const SectionShow ¶ms = SectionShow::Way::ClearStack,
|
||||||
MsgId msgId = ShowAtUnreadMsgId) override;
|
MsgId msgId = ShowAtUnreadMsgId) override;
|
||||||
|
|
||||||
void showPeerHistoryAtItem(not_null<const HistoryItem*> item);
|
void showMessage(not_null<const HistoryItem*> item);
|
||||||
void cancelUploadLayer(not_null<HistoryItem*> item);
|
void cancelUploadLayer(not_null<HistoryItem*> item);
|
||||||
|
|
||||||
void showLayer(
|
void showLayer(
|
||||||
|
|
Loading…
Add table
Reference in a new issue