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