Support new stories link t.me/username/s/123.
This commit is contained in:
parent
eb260b91c1
commit
80bec508b6
|
@ -779,7 +779,7 @@ QString ApiWrap::exportDirectStoryLink(not_null<Data::Story*> story) {
|
||||||
const auto fallback = [&] {
|
const auto fallback = [&] {
|
||||||
const auto base = user->username();
|
const auto base = user->username();
|
||||||
const auto story = QString::number(storyId.story);
|
const auto story = QString::number(storyId.story);
|
||||||
const auto query = base + "?story=" + story;
|
const auto query = base + "/s" + story;
|
||||||
return session().createInternalLinkFull(query);
|
return session().createInternalLinkFull(query);
|
||||||
};
|
};
|
||||||
const auto i = _unlikelyStoryLinks.find(storyId);
|
const auto i = _unlikelyStoryLinks.find(storyId);
|
||||||
|
|
|
@ -383,7 +383,8 @@ bool ResolveUsernameOrPhone(
|
||||||
if (const auto postId = postParam.toInt()) {
|
if (const auto postId = postParam.toInt()) {
|
||||||
post = postId;
|
post = postId;
|
||||||
}
|
}
|
||||||
const auto storyId = params.value(u"story"_q).toInt();
|
const auto storyParam = params.value(u"story"_q);
|
||||||
|
const auto storyId = storyParam.toInt();
|
||||||
const auto appname = params.value(u"appname"_q);
|
const auto appname = params.value(u"appname"_q);
|
||||||
const auto appstart = params.value(u"startapp"_q);
|
const auto appstart = params.value(u"startapp"_q);
|
||||||
const auto commentParam = params.value(u"comment"_q);
|
const auto commentParam = params.value(u"comment"_q);
|
||||||
|
@ -423,7 +424,7 @@ bool ResolveUsernameOrPhone(
|
||||||
.startToken = startToken,
|
.startToken = startToken,
|
||||||
.startAdminRights = adminRights,
|
.startAdminRights = adminRights,
|
||||||
.startAutoSubmit = myContext.botStartAutoSubmit,
|
.startAutoSubmit = myContext.botStartAutoSubmit,
|
||||||
.botAppName = appname.isEmpty() ? postParam : appname,
|
.botAppName = (appname.isEmpty() ? postParam : appname),
|
||||||
.botAppForceConfirmation = myContext.mayShowConfirmation,
|
.botAppForceConfirmation = myContext.mayShowConfirmation,
|
||||||
.attachBotUsername = params.value(u"attach"_q),
|
.attachBotUsername = params.value(u"attach"_q),
|
||||||
.attachBotToggleCommand = (params.contains(u"startattach"_q)
|
.attachBotToggleCommand = (params.contains(u"startattach"_q)
|
||||||
|
@ -1029,6 +1030,7 @@ QString TryConvertUrlToLocal(QString url) {
|
||||||
"/?$|"
|
"/?$|"
|
||||||
"/[a-zA-Z0-9\\.\\_]+/?(\\?|$)|"
|
"/[a-zA-Z0-9\\.\\_]+/?(\\?|$)|"
|
||||||
"/\\d+/?(\\?|$)|"
|
"/\\d+/?(\\?|$)|"
|
||||||
|
"/s/\\d+/?(\\?|$)|"
|
||||||
"/\\d+/\\d+/?(\\?|$)"
|
"/\\d+/\\d+/?(\\?|$)"
|
||||||
")"_q, query, matchOptions)) {
|
")"_q, query, matchOptions)) {
|
||||||
const auto params = query.mid(usernameMatch->captured(0).size()).toString();
|
const auto params = query.mid(usernameMatch->captured(0).size()).toString();
|
||||||
|
@ -1038,6 +1040,8 @@ QString TryConvertUrlToLocal(QString url) {
|
||||||
added = u"&topic=%1&post=%2"_q.arg(threadPostMatch->captured(1)).arg(threadPostMatch->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))) {
|
} else if (const auto postMatch = regex_match(u"^/(\\d+)(/?\\?|/?$)"_q, usernameMatch->captured(2))) {
|
||||||
added = u"&post="_q + postMatch->captured(1);
|
added = u"&post="_q + postMatch->captured(1);
|
||||||
|
} else if (const auto storyMatch = regex_match(u"^/s/(\\d+)(/?\\?|/?$)"_q, usernameMatch->captured(2))) {
|
||||||
|
added = u"&story="_q + storyMatch->captured(1);
|
||||||
} else if (const auto appNameMatch = regex_match(u"^/([a-zA-Z0-9\\.\\_]+)(/?\\?|/?$)"_q, usernameMatch->captured(2))) {
|
} else if (const auto appNameMatch = regex_match(u"^/([a-zA-Z0-9\\.\\_]+)(/?\\?|/?$)"_q, usernameMatch->captured(2))) {
|
||||||
added = u"&appname="_q + appNameMatch->captured(1);
|
added = u"&appname="_q + appNameMatch->captured(1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user