mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 23:27:09 +02:00
Fix mention links to groups and channels.
This commit is contained in:
parent
d25bd2f481
commit
205cd3b751
5 changed files with 26 additions and 29 deletions
|
@ -176,7 +176,7 @@ void MentionClickHandler::onClick(ClickContext context) const {
|
|||
using Info = Window::SessionNavigation::PeerByLinkInfo;
|
||||
m->controller()->showPeerByLink(Info{
|
||||
.usernameOrId = _tag.mid(1),
|
||||
.messageId = ShowAtProfileMsgId
|
||||
.resolveType = Window::ResolveType::Mention,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -330,22 +330,21 @@ bool ResolveUsernameOrPhone(
|
|||
} else if (!validDomain(domain) && !validPhone(phone)) {
|
||||
return false;
|
||||
}
|
||||
using BotStartType = Window::BotStartType;
|
||||
auto startType = BotStartType::None;
|
||||
using ResolveType = Window::ResolveType;
|
||||
auto resolveType = ResolveType::Default;
|
||||
auto startToken = params.value(u"start"_q);
|
||||
if (!startToken.isEmpty()) {
|
||||
startType = BotStartType::Personal;
|
||||
resolveType = ResolveType::BotStart;
|
||||
} else if (params.contains(u"startgroup"_q)) {
|
||||
startType = BotStartType::Group;
|
||||
resolveType = ResolveType::AddToGroup;
|
||||
startToken = params.value(u"startgroup"_q);
|
||||
} else if (params.contains(u"startchannel"_q)) {
|
||||
startType = BotStartType::Channel;
|
||||
resolveType = ResolveType::AddToChannel;
|
||||
}
|
||||
auto post = ShowAtUnreadMsgId;
|
||||
auto adminRights = ChatAdminRights();
|
||||
if (startType == BotStartType::Group
|
||||
|| startType == BotStartType::Channel) {
|
||||
post = ShowAtProfileMsgId;
|
||||
if (resolveType == ResolveType::AddToGroup
|
||||
|| resolveType == ResolveType::AddToChannel) {
|
||||
adminRights = ParseRequestedAdminRights(params.value(u"admin"_q));
|
||||
}
|
||||
const auto postParam = params.value(qsl("post"));
|
||||
|
@ -359,8 +358,7 @@ bool ResolveUsernameOrPhone(
|
|||
const auto gameParam = params.value(qsl("game"));
|
||||
if (!gameParam.isEmpty() && validDomain(gameParam)) {
|
||||
startToken = gameParam;
|
||||
post = ShowAtProfileMsgId;
|
||||
startType = BotStartType::ShareGame;
|
||||
resolveType = ResolveType::ShareGame;
|
||||
}
|
||||
const auto fromMessageId = context.value<ClickHandlerContext>().itemId;
|
||||
using Navigation = Window::SessionNavigation;
|
||||
|
@ -377,7 +375,7 @@ bool ResolveUsernameOrPhone(
|
|||
Navigation::ThreadId{ threadId }
|
||||
}
|
||||
: Navigation::RepliesByLinkInfo{ v::null },
|
||||
.startType = startType,
|
||||
.resolveType = resolveType,
|
||||
.startToken = startToken,
|
||||
.startAdminRights = adminRights,
|
||||
.attachBotUsername = params.value(u"attach"_q),
|
||||
|
|
|
@ -82,7 +82,6 @@ constexpr auto ShowAtUnreadMsgId = MsgId(0);
|
|||
constexpr auto SpecialMsgIdShift = EndClientMsgId.bare;
|
||||
constexpr auto ShowAtTheEndMsgId = MsgId(SpecialMsgIdShift + 1);
|
||||
constexpr auto SwitchAtTopMsgId = MsgId(SpecialMsgIdShift + 2);
|
||||
constexpr auto ShowAtProfileMsgId = MsgId(SpecialMsgIdShift + 3);
|
||||
constexpr auto ShowAndStartBotMsgId = MsgId(SpecialMsgIdShift + 4);
|
||||
constexpr auto ShowForChooseMessagesMsgId = MsgId(SpecialMsgIdShift + 6);
|
||||
|
||||
|
|
|
@ -317,14 +317,14 @@ void SessionNavigation::showPeerByLinkResolved(
|
|||
commentId->id,
|
||||
params);
|
||||
} else if (bot
|
||||
&& (info.startType == BotStartType::Group
|
||||
|| info.startType == BotStartType::Channel
|
||||
|| info.startType == BotStartType::ShareGame)) {
|
||||
const auto scope = (info.startType == BotStartType::ShareGame)
|
||||
&& (info.resolveType == ResolveType::AddToGroup
|
||||
|| info.resolveType == ResolveType::AddToChannel
|
||||
|| info.resolveType == ResolveType::ShareGame)) {
|
||||
const auto scope = (info.resolveType == ResolveType::ShareGame)
|
||||
? Scope::ShareGame
|
||||
: (info.startType == BotStartType::Group)
|
||||
: (info.resolveType == ResolveType::AddToGroup)
|
||||
? (info.startAdminRights ? Scope::GroupAdmin : Scope::All)
|
||||
: (info.startType == BotStartType::Channel)
|
||||
: (info.resolveType == ResolveType::AddToChannel)
|
||||
? Scope::ChannelAdmin
|
||||
: Scope::None;
|
||||
Assert(scope != Scope::None);
|
||||
|
@ -334,11 +334,10 @@ void SessionNavigation::showPeerByLinkResolved(
|
|||
scope,
|
||||
info.startToken,
|
||||
info.startAdminRights);
|
||||
} else if (info.messageId == ShowAtProfileMsgId) {
|
||||
if (bot) {
|
||||
// Always open bot chats, even from mention links.
|
||||
} else if (info.resolveType == ResolveType::Mention) {
|
||||
if (bot || peer->isChannel()) {
|
||||
crl::on_main(this, [=] {
|
||||
showPeerHistory(bot->id, params);
|
||||
showPeerHistory(peer->id, params);
|
||||
});
|
||||
} else {
|
||||
showPeerInfo(peer, params);
|
||||
|
|
|
@ -89,12 +89,13 @@ enum class GifPauseReason {
|
|||
using GifPauseReasons = base::flags<GifPauseReason>;
|
||||
inline constexpr bool is_flag_type(GifPauseReason) { return true; };
|
||||
|
||||
enum class BotStartType {
|
||||
None,
|
||||
Personal,
|
||||
Group,
|
||||
Channel,
|
||||
enum class ResolveType {
|
||||
Default,
|
||||
BotStart,
|
||||
AddToGroup,
|
||||
AddToChannel,
|
||||
ShareGame,
|
||||
Mention,
|
||||
};
|
||||
|
||||
struct PeerThemeOverride {
|
||||
|
@ -189,7 +190,7 @@ public:
|
|||
QString phone;
|
||||
MsgId messageId = ShowAtUnreadMsgId;
|
||||
RepliesByLinkInfo repliesInfo;
|
||||
BotStartType startType = BotStartType::None;
|
||||
ResolveType resolveType = ResolveType::Default;
|
||||
QString startToken;
|
||||
ChatAdminRights startAdminRights;
|
||||
QString attachBotUsername;
|
||||
|
|
Loading…
Add table
Reference in a new issue