Deep Link: Show notification when user has not access to the chat (#4443)

This commit is contained in:
Alexander Zinchuk 2024-03-30 22:42:35 +01:00
parent 8d2a2a5be1
commit aa588c8308
2 changed files with 19 additions and 22 deletions

View File

@ -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),

View File

@ -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) {