Links: Support ref parameter (#5328)
This commit is contained in:
parent
cbe277c08f
commit
f84930c7ac
@ -1493,7 +1493,7 @@ addActionHandler('acceptChatInvite', async (global, actions, payload): Promise<v
|
|||||||
addActionHandler('openChatByUsername', async (global, actions, payload): Promise<void> => {
|
addActionHandler('openChatByUsername', async (global, actions, payload): Promise<void> => {
|
||||||
const {
|
const {
|
||||||
username, messageId, commentId, startParam, startAttach, attach, threadId, originalParts, startApp, mode,
|
username, messageId, commentId, startParam, startAttach, attach, threadId, originalParts, startApp, mode,
|
||||||
text, onChatChanged, choose,
|
text, onChatChanged, choose, ref,
|
||||||
tabId = getCurrentTabId(),
|
tabId = getCurrentTabId(),
|
||||||
} = payload;
|
} = payload;
|
||||||
|
|
||||||
@ -1502,7 +1502,7 @@ addActionHandler('openChatByUsername', async (global, actions, payload): Promise
|
|||||||
const isWebApp = webAppName && !Number(webAppName) && !originalParts?.[2];
|
const isWebApp = webAppName && !Number(webAppName) && !originalParts?.[2];
|
||||||
|
|
||||||
if (!commentId) {
|
if (!commentId) {
|
||||||
if (startAttach === undefined && messageId && !startParam
|
if (startAttach === undefined && messageId && !startParam && !ref
|
||||||
&& chat?.usernames?.some((c) => c.username === username)) {
|
&& chat?.usernames?.some((c) => c.username === username)) {
|
||||||
actions.focusMessage({
|
actions.focusMessage({
|
||||||
chatId: chat.id, threadId, messageId, tabId,
|
chatId: chat.id, threadId, messageId, tabId,
|
||||||
@ -1542,6 +1542,7 @@ addActionHandler('openChatByUsername', async (global, actions, payload): Promise
|
|||||||
threadId,
|
threadId,
|
||||||
channelPostId: messageId,
|
channelPostId: messageId,
|
||||||
startParam,
|
startParam,
|
||||||
|
ref,
|
||||||
startAttach,
|
startAttach,
|
||||||
attach,
|
attach,
|
||||||
text,
|
text,
|
||||||
@ -3013,6 +3014,7 @@ async function openChatByUsername<T extends GlobalState>(
|
|||||||
threadId?: ThreadId;
|
threadId?: ThreadId;
|
||||||
channelPostId?: number;
|
channelPostId?: number;
|
||||||
startParam?: string;
|
startParam?: string;
|
||||||
|
ref?: string;
|
||||||
startAttach?: string;
|
startAttach?: string;
|
||||||
attach?: string;
|
attach?: string;
|
||||||
text?: string;
|
text?: string;
|
||||||
@ -3020,7 +3022,7 @@ async function openChatByUsername<T extends GlobalState>(
|
|||||||
...[tabId = getCurrentTabId()]: TabArgs<T>
|
...[tabId = getCurrentTabId()]: TabArgs<T>
|
||||||
) {
|
) {
|
||||||
const {
|
const {
|
||||||
username, threadId, channelPostId, startParam, startAttach, attach, text,
|
username, threadId, channelPostId, startParam, ref, startAttach, attach, text,
|
||||||
} = params;
|
} = params;
|
||||||
global = getGlobal();
|
global = getGlobal();
|
||||||
const currentChat = selectCurrentChat(global, tabId);
|
const currentChat = selectCurrentChat(global, tabId);
|
||||||
@ -3049,7 +3051,7 @@ async function openChatByUsername<T extends GlobalState>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const starRefStartPrefixes = global.appConfig?.starRefStartPrefixes;
|
const starRefStartPrefixes = global.appConfig?.starRefStartPrefixes;
|
||||||
let referrer = '';
|
let referrer = ref;
|
||||||
if (startParam && starRefStartPrefixes?.length) {
|
if (startParam && starRefStartPrefixes?.length) {
|
||||||
const prefix = starRefStartPrefixes.find((p) => startParam.startsWith(p));
|
const prefix = starRefStartPrefixes.find((p) => startParam.startsWith(p));
|
||||||
if (prefix) {
|
if (prefix) {
|
||||||
@ -3075,7 +3077,7 @@ async function openChatByUsername<T extends GlobalState>(
|
|||||||
actions.openThread({ chatId: chat.id, threadId: threadId ?? MAIN_THREAD_ID, tabId });
|
actions.openThread({ chatId: chat.id, threadId: threadId ?? MAIN_THREAD_ID, tabId });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (startParam) {
|
if (startParam && !referrer) {
|
||||||
actions.startBot({ botId: chat.id, param: startParam });
|
actions.startBot({ botId: chat.id, param: startParam });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1843,6 +1843,7 @@ export interface ActionPayloads {
|
|||||||
messageId?: number;
|
messageId?: number;
|
||||||
commentId?: number;
|
commentId?: number;
|
||||||
startParam?: string;
|
startParam?: string;
|
||||||
|
ref?: string;
|
||||||
startAttach?: string;
|
startAttach?: string;
|
||||||
attach?: string;
|
attach?: string;
|
||||||
startApp?: string;
|
startApp?: string;
|
||||||
|
|||||||
@ -60,6 +60,7 @@ interface PublicUsernameOrBotLink {
|
|||||||
type: 'publicUsernameOrBotLink';
|
type: 'publicUsernameOrBotLink';
|
||||||
username: string;
|
username: string;
|
||||||
start?: string;
|
start?: string;
|
||||||
|
ref?: string;
|
||||||
startApp?: string;
|
startApp?: string;
|
||||||
mode?: string;
|
mode?: string;
|
||||||
appName?: string;
|
appName?: string;
|
||||||
@ -206,6 +207,7 @@ function parseTgLink(url: URL) {
|
|||||||
startAttach: queryParams.startattach,
|
startAttach: queryParams.startattach,
|
||||||
attach: queryParams.attach,
|
attach: queryParams.attach,
|
||||||
choose: queryParams.choose,
|
choose: queryParams.choose,
|
||||||
|
ref: queryParams.ref,
|
||||||
});
|
});
|
||||||
case 'businessChatLink':
|
case 'businessChatLink':
|
||||||
return buildBusinessChatLink({ slug: queryParams.slug });
|
return buildBusinessChatLink({ slug: queryParams.slug });
|
||||||
@ -300,6 +302,7 @@ function parseHttpLink(url: URL) {
|
|||||||
startAttach: queryParams.startattach,
|
startAttach: queryParams.startattach,
|
||||||
attach: queryParams.attach,
|
attach: queryParams.attach,
|
||||||
choose: queryParams.choose,
|
choose: queryParams.choose,
|
||||||
|
ref: queryParams.ref,
|
||||||
});
|
});
|
||||||
case 'businessChatLink':
|
case 'businessChatLink':
|
||||||
return buildBusinessChatLink({ slug: pathParams[1] });
|
return buildBusinessChatLink({ slug: pathParams[1] });
|
||||||
@ -531,6 +534,7 @@ function buildPublicUsernameOrBotLink(
|
|||||||
attach,
|
attach,
|
||||||
appName,
|
appName,
|
||||||
choose,
|
choose,
|
||||||
|
ref,
|
||||||
} = params;
|
} = params;
|
||||||
if (!username) {
|
if (!username) {
|
||||||
return undefined;
|
return undefined;
|
||||||
@ -549,6 +553,7 @@ function buildPublicUsernameOrBotLink(
|
|||||||
attach,
|
attach,
|
||||||
text,
|
text,
|
||||||
choose,
|
choose,
|
||||||
|
ref,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -22,6 +22,7 @@ export const processDeepLink = (url: string): boolean => {
|
|||||||
actions.openChatByUsername({
|
actions.openChatByUsername({
|
||||||
username: parsedLink.username,
|
username: parsedLink.username,
|
||||||
startParam: parsedLink.start,
|
startParam: parsedLink.start,
|
||||||
|
ref: parsedLink.ref,
|
||||||
text: parsedLink.text,
|
text: parsedLink.text,
|
||||||
startApp: parsedLink.startApp,
|
startApp: parsedLink.startApp,
|
||||||
mode: parsedLink.mode,
|
mode: parsedLink.mode,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user