diff --git a/Telegram/SourceFiles/core/click_handler_types.cpp b/Telegram/SourceFiles/core/click_handler_types.cpp index 160eaad15..67f7a84ea 100644 --- a/Telegram/SourceFiles/core/click_handler_types.cpp +++ b/Telegram/SourceFiles/core/click_handler_types.cpp @@ -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, }); } } diff --git a/Telegram/SourceFiles/core/local_url_handlers.cpp b/Telegram/SourceFiles/core/local_url_handlers.cpp index d54f2cb71..5ad280e29 100644 --- a/Telegram/SourceFiles/core/local_url_handlers.cpp +++ b/Telegram/SourceFiles/core/local_url_handlers.cpp @@ -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().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), diff --git a/Telegram/SourceFiles/data/data_msg_id.h b/Telegram/SourceFiles/data/data_msg_id.h index 018722046..9f884b429 100644 --- a/Telegram/SourceFiles/data/data_msg_id.h +++ b/Telegram/SourceFiles/data/data_msg_id.h @@ -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); diff --git a/Telegram/SourceFiles/window/window_session_controller.cpp b/Telegram/SourceFiles/window/window_session_controller.cpp index 2362b6b97..776115b3a 100644 --- a/Telegram/SourceFiles/window/window_session_controller.cpp +++ b/Telegram/SourceFiles/window/window_session_controller.cpp @@ -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); diff --git a/Telegram/SourceFiles/window/window_session_controller.h b/Telegram/SourceFiles/window/window_session_controller.h index c93744d9e..907f1c9a4 100644 --- a/Telegram/SourceFiles/window/window_session_controller.h +++ b/Telegram/SourceFiles/window/window_session_controller.h @@ -89,12 +89,13 @@ enum class GifPauseReason { using GifPauseReasons = base::flags; 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;