diff --git a/src/global/actions/api/chats.ts b/src/global/actions/api/chats.ts index 1407cf13a..529cb1205 100644 --- a/src/global/actions/api/chats.ts +++ b/src/global/actions/api/chats.ts @@ -1263,20 +1263,12 @@ addActionHandler('openTelegramLink', (global, actions, payload): ActionReturnTyp tabId = getCurrentTabId(), } = payload; - if (isDeepLink(url)) { - const isProcessed = processDeepLink(url); - if (isProcessed || url.match(RE_TG_LINK)) { - return; - } - } - const { openChatByPhoneNumber, openChatByInvite, openStickerSet, openChatWithDraft, joinVoiceChatByLink, - showNotification, focusMessage, openInvoice, processAttachBotParameters, @@ -1287,6 +1279,13 @@ addActionHandler('openTelegramLink', (global, actions, payload): ActionReturnTyp checkGiftCode, } = actions; + if (isDeepLink(url)) { + const isProcessed = processDeepLink(url); + if (isProcessed || url.match(RE_TG_LINK)) { + return; + } + } + const uri = new URL(url.toLowerCase().startsWith('http') ? url : `https://${url}`); if (TME_WEB_DOMAINS.has(uri.hostname) && uri.pathname === '/') { window.open(uri.toString(), '_blank', 'noopener'); @@ -1397,20 +1396,11 @@ addActionHandler('openTelegramLink', (global, actions, payload): ActionReturnTyp tabId, }); } else if (part1 === 'c' && chatOrChannelPostId && messageId) { - const chatId = toChannelId(chatOrChannelPostId); - const chat = selectChat(global, chatId); - if (!chat) { - showNotification({ message: 'Chat does not exist', tabId }); - return; - } - - if (messageId) { - focusMessage({ - chatId: chat.id, - messageId, - tabId, - }); - } + focusMessage({ + chatId: toChannelId(chatOrChannelPostId), + messageId, + tabId, + }); } else if (part1.startsWith('$')) { openInvoice({ slug: part1.substring(1), diff --git a/src/global/actions/ui/messages.ts b/src/global/actions/ui/messages.ts index fa4658acd..523eeaddf 100644 --- a/src/global/actions/ui/messages.ts +++ b/src/global/actions/ui/messages.ts @@ -16,6 +16,7 @@ import { copyHtmlToClipboard } from '../../../util/clipboard'; import { getCurrentTabId } from '../../../util/establishMultitabRole'; import { compact, findLast } from '../../../util/iteratees'; import * as langProvider from '../../../util/langProvider'; +import { translate } from '../../../util/langProvider'; import parseHtmlAsFormattedText from '../../../util/parseHtmlAsFormattedText'; import { getServerTime } from '../../../util/serverTime'; import { IS_TOUCH_ENV } from '../../../util/windowEnvironment'; @@ -402,6 +403,12 @@ addActionHandler('focusMessage', (global, actions, payload): ActionReturnType => let { messageId } = payload; + const chat = selectChat(global, chatId); + if (!chat) { + actions.showNotification({ message: translate('Conversation.ErrorInaccessibleMessage'), tabId }); + return undefined; + } + if (groupedId !== undefined) { const ids = selectForwardedMessageIdsByGroupId(global, groupedChatId!, groupedId); if (ids?.length) {