// Metro module 16731 (f16732). import ChannelStore from "../../../stores/ChannelStore"; import RTCConnectionStore from "../../../stores/RTCConnectionStore"; import AppStateStore from "../../../stores/native/AppStateStore"; import { AnalyticEvents, AppStates, LinkingTypes } from "../../../Constants"; import Logger from "../../debug/Logger"; import { trackAppOpened } from "../../tti_analytics/native/TTIAnalyticsUtils"; import { DeeplinkSource } from "../../deep_link/DeepLinkTypes"; import { navigateToVoiceChannel } from "../../../utils/native/PrivateChannelCallUtils"; import AnalyticsUtils from "../../../utils/AnalyticsUtils"; import handleSupportedURL from "./handleSupportedURL"; import parseURL from "../../../utils/native/parseURL"; import { parseInviteCodeFromInviteKey } from "../../instant_invite/InviteCodeUtils"; import { extractId } from "../../../_bundle/Module513"; import InstantInviteActionCreators from "../../../actions/InstantInviteActionCreators"; import externalFingerprint from "../../auth/externalFingerprint"; import { HermesBuiltin } from "../../../_hermes/prelude"; let c12059_10 = new Logger("index.native.tsx"); export default async function handleIncomingURL(c28510_0, c28510_1) { let c28510_2, c28510_3, c28510_4, c28510_5; let c28510_6 = 0; const r42 = "Empty or whitespace-only URL fragment in AppsFlyer legacy URL"; const r14 = void 0; L105: { L104: { L94: { L93: { L92: { L77: { L20: { try { let env31108; c28510_4 = r14; const r47 = env31108 = {}; c28510_3 = r47; env31108[0] = c28510_0; env31108[1] = c28510_1; env31108[2] = void 0; env31108[3] = void 0; env31108[4] = void 0; env31108[5] = void 0; env31108[6] = void 0; env31108[7] = void 0; env31108[8] = void 0; env31108[9] = void 0; env31108[10] = void 0; env31108[11] = void 0; env31108[12] = void 0; env31108[13] = void 0; env31108[14] = void 0; env31108[15] = void 0; env31108[2] = c28510_0.url; env31108[3] = c28510_0.source; c12059_10.log(`Opening url: ${env31108[2]} [${env31108[3]}]`); if (AppStateStore.getState() !== AppStates.ACTIVE) { trackAppOpened(env31108[2] == null ? "launcher" : "deeplink"); } if (env31108[2] == null) { break L105; } L13: { if (env31108[2].startsWith("discord://app/open")) { const r97 = env31108[2].indexOf("#"); if (r97 !== -1) { const r101 = env31108[2].substring(r97 + 1); env31108[4] = r101; if (r101 !== "" && r101.trim() !== "") { c28510_6 = 1; const uRL = new URL(r101); env31108[5] = uRL; env31108[6] = ["campaign", "deep_link_value", "media_source"]; c28510_2 = 0; const r123 = uRL.searchParams.keys(); const r124 = []; c28510_2 = HermesBuiltin.arraySpread(r124, r123, c28510_2); r124.filter((item) => item.startsWith("af_") || env31108[6].includes(item)).forEach((item) => env31108[5].searchParams.delete(item)); env31108[2] = uRL.toString(); env31108[3] = DeeplinkSource.AppsFlyer; c12059_10.log(`Extracted clean URL from AppsFlyer legacy URL: ${env31108[2]}`); c28510_6 = 0; break L13; } c12059_10.warn(r42, { originalUrl: env31108[2] }); break L20; } c12059_10.warn("No hash mark found in AppsFlyer legacy URL", { originalUrl: env31108[2] }); } } if (env31108[2].startsWith("discordwidget:///")) { if (env31108[2].startsWith("discordwidget:///open-voice-panel")) { const channelId = RTCConnectionStore.getChannelId(); const r480 = channelId != null ? ChannelStore.getChannel(channelId) : null; if (r480 == null) { break L104; } navigateToVoiceChannel(r480, "LiveActivity"); const r553 = env31108[2].indexOf("?"); const surface = new URLSearchParams(r553 >= 0 ? env31108[2].slice(r553 + 1) : "").get("source"); if (surface !== "lockScreen" && surface !== "dynamicIsland") { break L104; } AnalyticsUtils.track(AnalyticEvents.LIVE_ACTIVITY_INTERACTED, { action: "Open Voice Panel", channel_id: r480.id, surface }); break L104; } const r483 = env31108[2].split("voice/"); if (r483.length !== 2) { break L94; } const r488 = r483[1].split("/"); if (r488.length === 0) { break L93; } if (r488[0] === "user") { break L105; } if (r488[0] === "invite") { handleSupportedURL({ payload: { type: LinkingTypes.CREATE_VOICE_INVITE, guildId: r488[1], channelId: r488[2] } }); break L105; } if (r488[0] === "wave") { handleSupportedURL({ payload: { type: LinkingTypes.SEND_VOICE_HANGOUT_WAVE, guildId: r488[1], channelId: r488[2] } }); break L105; } if (r488[0] === "join") { handleSupportedURL({ payload: { type: LinkingTypes.CHANNEL, guildId: r488[1], channelId: r488[2] } }); break L105; } if (r488.length !== 2) { break L105; } handleSupportedURL({ payload: { type: LinkingTypes.CHANNEL, guildId: r488[0], channelId: r488[1] } }); break L92; } if (new URL(env31108[2]).hostname === "l.discord.com") { env31108[2] = (await fetch(env31108[2], { method: "HEAD", redirect: "follow" })).url; env31108[3] = DeeplinkSource.Iterable; env31108[7] = parseURL(env31108[2], true); env31108[8] = env31108[7].fingerprint; env31108[9] = env31108[7].attemptId; env31108[10] = env31108[7].payload; env31108[11] = env31108[7].installationId; c12059_10.log("Parsed url as: ", env31108[7]); env31108[12] = env31108[10].inviteCode; env31108[13] = env31108[10].guildTemplateCode; env31108[14] = env31108[10].authToken; env31108[15] = env31108[12] != null ? parseInviteCodeFromInviteKey(env31108[12]) : null; if (!(env31108[8] == null && env31108[9] == null && env31108[12] == null && env31108[13] == null && env31108[14] == null && env31108[3] == null && env31108[11] == null)) { const EXTERNAL_DYNAMIC_LINK_RECEIVED2 = AnalyticEvents.EXTERNAL_DYNAMIC_LINK_RECEIVED; AnalyticsUtils.track(EXTERNAL_DYNAMIC_LINK_RECEIVED2, { invite_code: env31108[15], guild_template_code: env31108[13], has_auth_token: env31108[14] != null && env31108[14].length === 0, is_backgrounded: AppStateStore.getState() === AppStates.BACKGROUND, attempt_id: env31108[9], deeplink_source: env31108[3], link_type: env31108[10].type, is_cold_start: env31108[1], received_installation_id: env31108[11], ...env31108[8] != null ? { fingerprint: extractId(env31108[8]) } : null }); } if (env31108[15] != null && env31108[11] != null) { InstantInviteActionCreators.setReceivedInstallationIdForInviteCode(env31108[15], env31108[11]); } externalFingerprint(env31108[2]); handleSupportedURL({ payload: env31108[10] }); break L77; } env31108[7] = parseURL(env31108[2], true); env31108[8] = env31108[7].fingerprint; env31108[9] = env31108[7].attemptId; env31108[10] = env31108[7].payload; env31108[11] = env31108[7].installationId; c12059_10.log("Parsed url as: ", env31108[7]); env31108[12] = env31108[10].inviteCode; env31108[13] = env31108[10].guildTemplateCode; env31108[14] = env31108[10].authToken; env31108[15] = env31108[12] != null ? parseInviteCodeFromInviteKey(env31108[12]) : null; if (!(env31108[8] == null && env31108[9] == null && env31108[12] == null && env31108[13] == null && env31108[14] == null && env31108[3] == null && env31108[11] == null)) { const EXTERNAL_DYNAMIC_LINK_RECEIVED = AnalyticEvents.EXTERNAL_DYNAMIC_LINK_RECEIVED; AnalyticsUtils.track(EXTERNAL_DYNAMIC_LINK_RECEIVED, { invite_code: env31108[15], guild_template_code: env31108[13], has_auth_token: env31108[14] != null && env31108[14].length === 0, is_backgrounded: AppStateStore.getState() === AppStates.BACKGROUND, attempt_id: env31108[9], deeplink_source: env31108[3], link_type: env31108[10].type, is_cold_start: env31108[1], received_installation_id: env31108[11], ...env31108[8] != null ? { fingerprint: extractId(env31108[8]) } : null }); } if (env31108[15] != null && env31108[11] != null) { InstantInviteActionCreators.setReceivedInstallationIdForInviteCode(env31108[15], env31108[11]); } externalFingerprint(env31108[2]); handleSupportedURL({ payload: env31108[10] }); break L105; } catch ($e) { const r64 = $e; let r8 = r64; c28510_5 = r64; if (c28510_6 !== 0) { while (true) { try { const r585 = c28510_5; c28510_6 = 0; env31108[16] = r585; c12059_10.warn("Failed to parse URL from AppsFlyer legacy URL", { originalUrl: env31108[0].url, extractedUrlString: env31108[4], error: env31108[16].message }); } catch (r581) { r8 = r581; c28510_5 = r581; if (c28510_6 === 0) { break; } continue; } return void 0; } } throw r8; } } return void 0; } return void 0; } return void 0; } return void 0; } return void 0; } return void 0; } };