510 lines
18 KiB
TypeScript
510 lines
18 KiB
TypeScript
// Metro module 8207 (f8208).
|
|
import ApplicationStore from "../modules/applications/ApplicationStore";
|
|
import "../modules/guild_scheduled_events/GuildScheduledEventStore";
|
|
import "../modules/slayer_storefront/SocialLayerStorefrontStore";
|
|
import AuthenticationStore from "../stores/AuthenticationStore";
|
|
import GuildMemberStore from "../stores/GuildMemberStore";
|
|
import "../stores/GuildStore";
|
|
import InviteStore from "../stores/InviteStore";
|
|
import "../stores/MessageStore";
|
|
import SelectedChannelStore from "../stores/SelectedChannelStore";
|
|
import SelectedGuildStore from "../stores/SelectedGuildStore";
|
|
import SortedGuildStore from "../stores/SortedGuildStore";
|
|
import { InviteStates, AbortCodes, AppContext, JoinGuildSources, Routes, AnalyticEvents } from "../Constants";
|
|
import { CollectibleShopTab, CollectiblesMobileShopScreen } from "../modules/collectibles/CollectiblesShopConstants";
|
|
import { isGameShopPath } from "../modules/slayer_storefront/SocialLayerStorefrontConstants";
|
|
import Dispatcher from "../Dispatcher";
|
|
import { getInviteInstanceId } from "../modules/instant_invite/InviteCodeUtils";
|
|
import InstantInviteActionCreators from "../actions/InstantInviteActionCreators";
|
|
import safeTransitionTo_native from "../modules/links/safeTransitionTo.native";
|
|
import { findCodedLink } from "../modules/coded_links/findCodedLinks";
|
|
import { CodedLinkType } from "../modules/coded_links/CodedLink";
|
|
import { parseStorefrontSkuCodedLink } from "../modules/application_storefront/storefrontMessageEmbedCodedLink";
|
|
import openURL from "./openURL";
|
|
import AnalyticsUtils from "../utils/AnalyticsUtils";
|
|
import getEmbeddedActivitiesManager_native from "../modules/activities/utils/getEmbeddedActivitiesManager.native";
|
|
import { getPlayInContext } from "../modules/applications/message_embed/utils/getPlayInContext";
|
|
import { getCustomActivityLinkParams } from "../modules/activities/utils/CustomActivityLinkUtils";
|
|
import { runPrimaryAppCommandOrJoinEmbeddedActivity } from "../modules/activities/EmbeddedActivitiesActionCreators";
|
|
import ChannelActionCreators from "../actions/ChannelActionCreators";
|
|
import handleUsePrimaryEntryPointAppCommand from "../modules/activities/handleUsePrimaryEntryPointAppCommand";
|
|
import { openSocialLayerStorefrontProductDetailsModal, openSocialLayerStorefrontUnsupportedOnMobileAlert } from "../modules/slayer_storefront/native/SocialLayerStorefrontNativeActionCreators";
|
|
import { getIsEligibleForQuests } from "../modules/quests/lib/QuestsEligibility";
|
|
import URLUtils from "../utils/URLUtils";
|
|
import { openQuestHome } from "../modules/quests/native/QuestUtils.native";
|
|
import { QuestContent } from "../_bundle/Module5038";
|
|
import { isVirtualCurrencyEnabled } from "../modules/virtual_currency/hooks/native/useVirtualCurrencyMobileEnabled";
|
|
import AppAnalyticsUtils from "../modules/app_analytics/AppAnalyticsUtils";
|
|
import { tryParseEventDetailsPath } from "../modules/links/LinkUtils";
|
|
import { isSuspiciousDownload } from "../modules/suspicious_downloads/SuspiciousDownloadUtils";
|
|
import SuspiciousDownloadModalActionCreators_native from "../modules/suspicious_downloads/SuspiciousDownloadModalActionCreators.native";
|
|
function $mk115124($env) {
|
|
return (a0) => !$env[9].has(a0.id);
|
|
}
|
|
let c5215_20;
|
|
let env5215 = {};
|
|
const openInviteModal = async function openInviteModal(a0, code, invite_instance_id) {
|
|
await Dispatcher.dispatch({
|
|
type: "DISPLAYED_INVITE_SHOW",
|
|
code,
|
|
username: void 0,
|
|
deeplinkAttemptId: void 0,
|
|
invite_instance_id
|
|
});
|
|
};
|
|
env5215[19] = function _handleInviteCodedLink() {
|
|
const r8 = async (c26135_0, c26135_1) => {
|
|
let invite, roles, c26135_4, c26135_5;
|
|
L67: {
|
|
L41: {
|
|
L39: {
|
|
L42: {
|
|
let env29904;
|
|
c26135_5 = env5215;
|
|
const r14 = env29904 = {};
|
|
c26135_4 = r14;
|
|
env29904[0] = void 0;
|
|
env29904[1] = void 0;
|
|
env29904[2] = void 0;
|
|
env29904[3] = void 0;
|
|
env29904[4] = void 0;
|
|
env29904[5] = void 0;
|
|
env29904[6] = void 0;
|
|
env29904[7] = void 0;
|
|
env29904[8] = void 0;
|
|
env29904[9] = void 0;
|
|
const code2 = c26135_0.code;
|
|
env29904[0] = code2;
|
|
const inviteInstanceId = getInviteInstanceId(code2, c26135_1);
|
|
env29904[1] = inviteInstanceId;
|
|
env29904[2] = InviteStore.getInvite(code2);
|
|
if (env29904[2] != null && env29904[2].state !== InviteStates.ERROR) {
|
|
if (env29904[2] == null) {
|
|
break L67;
|
|
}
|
|
if (env29904[2].state !== InviteStates.EXPIRED && env29904[2].state !== InviteStates.BANNED && env29904[2].state !== InviteStates.ERROR) {
|
|
env29904[3] = SortedGuildStore.getFlattenedGuildIds();
|
|
const r244 = env29904[2];
|
|
env29904[4] = r244 == null ? void 0 : r244.guild?.id;
|
|
env29904[5] = env29904[4] != null && env29904[3].includes(env29904[4]);
|
|
env29904[6] = false;
|
|
if (env29904[5] && env29904[2].roles != null && env29904[2].roles.length > 0) {
|
|
env29904[7] = AuthenticationStore.getId();
|
|
env29904[8] = GuildMemberStore.getMember(env29904[4], env29904[7]);
|
|
const r279 = Set;
|
|
roles = env29904[8]?.roles;
|
|
if (roles == null) {
|
|
roles = [];
|
|
}
|
|
const r283 = c26135_4;
|
|
env29904[9] = new r279(roles);
|
|
env29904[6] = env29904[2].roles.some($mk115124(r283));
|
|
}
|
|
if (env29904[5] && !env29904[6]) {
|
|
InstantInviteActionCreators.transitionToInvite(env29904[2], {
|
|
forceTransition: true
|
|
});
|
|
break L67;
|
|
}
|
|
await (0, openInviteModal)(env29904[2], env29904[0], env29904[1]);
|
|
break L39;
|
|
}
|
|
await (0, openInviteModal)(env29904[2], env29904[0], env29904[1]);
|
|
break L41;
|
|
}
|
|
invite = (await InstantInviteActionCreators.resolveInvite(code2, "Markdown Link", {
|
|
inviteInstanceId
|
|
})).invite;
|
|
if (invite == null) {
|
|
invite = void 0;
|
|
}
|
|
env29904[2] = invite;
|
|
if (env29904[2] != null) {
|
|
if (env29904[2].state !== InviteStates.EXPIRED && env29904[2].state !== InviteStates.BANNED && env29904[2].state !== InviteStates.ERROR) {
|
|
env29904[3] = SortedGuildStore.getFlattenedGuildIds();
|
|
const r117 = env29904[2];
|
|
env29904[4] = r117 == null ? void 0 : r117.guild?.id;
|
|
env29904[5] = env29904[4] != null && env29904[3].includes(env29904[4]);
|
|
env29904[6] = false;
|
|
if (env29904[5] && env29904[2].roles != null && env29904[2].roles.length > 0) {
|
|
env29904[7] = AuthenticationStore.getId();
|
|
env29904[8] = GuildMemberStore.getMember(env29904[4], env29904[7]);
|
|
const r152 = Set;
|
|
roles = env29904[8]?.roles;
|
|
if (roles == null) {
|
|
roles = [];
|
|
}
|
|
const r156 = c26135_4;
|
|
env29904[9] = new r152(roles);
|
|
env29904[6] = env29904[2].roles.some($mk115124(r156));
|
|
}
|
|
if (env29904[5] && !env29904[6]) {
|
|
InstantInviteActionCreators.transitionToInvite(env29904[2], {
|
|
forceTransition: true
|
|
});
|
|
break L42;
|
|
}
|
|
await (0, openInviteModal)(env29904[2], env29904[0], env29904[1]);
|
|
break L39;
|
|
}
|
|
await (0, openInviteModal)(env29904[2], env29904[0], env29904[1]);
|
|
break L41;
|
|
}
|
|
}
|
|
return void 0;
|
|
}
|
|
return void 0;
|
|
}
|
|
return void 0;
|
|
}
|
|
};
|
|
env5215[19] = r8;
|
|
return r8.apply(this, arguments);
|
|
};
|
|
AbortCodes;
|
|
AppContext;
|
|
JoinGuildSources;
|
|
Routes;
|
|
c5215_20 = {
|
|
skipExtensionCheck: void 0,
|
|
analyticsLocations: []
|
|
};
|
|
export default function getOnClick(a0) {
|
|
let r24, r109, skipExtensionCheck;
|
|
let env16348 = {
|
|
$parent: env5215
|
|
};
|
|
env16348[0] = a0;
|
|
let r5 = arguments[1];
|
|
if (r5 === void 0) {
|
|
r5 = c5215_20;
|
|
}
|
|
L5: {
|
|
skipExtensionCheck = r5.skipExtensionCheck;
|
|
env16348[1] = r5.analyticsLocations;
|
|
env16348[2] = r5.messageId;
|
|
r5.channelId;
|
|
env16348[3] = void 0;
|
|
env16348[4] = void 0;
|
|
env16348[5] = void 0;
|
|
r24 = findCodedLink(a0);
|
|
env16348[3] = r24;
|
|
if (r24 != null) {
|
|
if (r24.type !== CodedLinkType.INVITE && r24.type !== CodedLinkType.EMBEDDED_ACTIVITY_INVITE) {
|
|
break L5;
|
|
}
|
|
return (a0) => {
|
|
if (a0 != null) {
|
|
a0.preventDefault();
|
|
}
|
|
(function handleInviteCodedLink() {
|
|
return env5215[19].apply(this, arguments);
|
|
})(env16348[3], env16348[2]);
|
|
return true;
|
|
};
|
|
}
|
|
}
|
|
L9: {
|
|
if (r24 != null) {
|
|
if (r24.type !== CodedLinkType.APP_DIRECTORY_PROFILE && r24.type !== CodedLinkType.APP_DIRECTORY_STOREFRONT && r24.type !== CodedLinkType.APP_DIRECTORY_STOREFRONT_SKU) {
|
|
break L9;
|
|
}
|
|
return (a0) => {
|
|
let r25;
|
|
if (a0 != null) {
|
|
a0.preventDefault();
|
|
}
|
|
L8: {
|
|
const r5 = env16348[3];
|
|
const code2 = r5.code;
|
|
if (r5.type !== CodedLinkType.APP_DIRECTORY_PROFILE && r5.type !== CodedLinkType.APP_DIRECTORY_STOREFRONT) {
|
|
r25 = parseStorefrontSkuCodedLink(code2);
|
|
if (r25 != null) {
|
|
break L8;
|
|
}
|
|
r25 = {
|
|
applicationId: void 0,
|
|
skuId: void 0
|
|
};
|
|
} else {
|
|
r25 = {
|
|
applicationId: code2,
|
|
skuId: void 0
|
|
};
|
|
}
|
|
}
|
|
const applicationId = r25.applicationId;
|
|
r25.skuId;
|
|
let guild_id = SelectedGuildStore.getGuildId();
|
|
if (guild_id == null) {
|
|
guild_id = void 0;
|
|
}
|
|
if (applicationId != null) {
|
|
AnalyticsUtils.track(AnalyticEvents.APP_DIRECTORY_PROFILE_EMBED_URL_CLICKED, {
|
|
application_id: applicationId,
|
|
device_platform: "mobile_native",
|
|
guild_id,
|
|
channel_id: SelectedChannelStore.getChannelId()
|
|
});
|
|
}
|
|
openURL(env16348[0]);
|
|
return true;
|
|
};
|
|
}
|
|
}
|
|
if (r24 != null && r24.type === CodedLinkType.ACTIVITY_BOOKMARK) {
|
|
return (a0) => {
|
|
if (a0 != null) {
|
|
a0.preventDefault();
|
|
}
|
|
let env26136 = {
|
|
$parent: env16348
|
|
};
|
|
const r24 = env16348[3];
|
|
const code2 = r24.code;
|
|
env26136[0] = code2;
|
|
const url = r24.url;
|
|
const application = ApplicationStore.getApplication(code2);
|
|
const uRL = new URL(url);
|
|
env26136[1] = uRL;
|
|
let r33 = uRL.searchParams.get("referrer_id");
|
|
if (r33 == null) {
|
|
r33 = void 0;
|
|
}
|
|
env26136[2] = r33;
|
|
env26136[3] = getEmbeddedActivitiesManager_native();
|
|
const playInContext = getPlayInContext(code2);
|
|
const currentChannelId = playInContext.currentChannelId;
|
|
env26136[4] = currentChannelId;
|
|
env26136[5] = playInContext.instanceId;
|
|
const isCurrentlyInInstance = playInContext.isCurrentlyInInstance;
|
|
if (playInContext.canLaunchInChannel) {
|
|
let r62 = isCurrentlyInInstance ? !isCurrentlyInInstance : currentChannelId != null;
|
|
if (r62) {
|
|
const customActivityLinkParams = getCustomActivityLinkParams(code2, uRL.searchParams.get("link_id"), uRL.searchParams.get("custom_id"));
|
|
let c26138_0 = async (c31449_0) => {
|
|
let c31449_2;
|
|
c31449_2 = void 0;
|
|
let c31973_0 = c31449_0.customId;
|
|
await void 0;
|
|
const r11 = c31449_2;
|
|
const r12 = r11.$parent;
|
|
await runPrimaryAppCommandOrJoinEmbeddedActivity({
|
|
channelId: r12[4],
|
|
applicationId: r12[0],
|
|
isStart: r12[5] == null,
|
|
embeddedActivitiesManager: r12[3],
|
|
customId: c31973_0,
|
|
referrerId: r12[2],
|
|
analyticsLocations: r11.$parent.$parent[1]
|
|
});
|
|
};
|
|
customActivityLinkParams.then(function() {
|
|
return c26138_0.apply(this, arguments);
|
|
}).catch(() => {});
|
|
r62 = true;
|
|
}
|
|
return r62;
|
|
}
|
|
const recipientIds = application == null ? void 0 : application.bot?.id;
|
|
let r47 = recipientIds != null;
|
|
if (r47) {
|
|
const r52 = ChannelActionCreators.openPrivateChannel({
|
|
recipientIds
|
|
});
|
|
let c26137_0 = async (c31450_0) => {
|
|
let c31450_2;
|
|
c31450_2 = void 0;
|
|
let c31974_0 = c31450_0;
|
|
const r33 = env26136[0];
|
|
const r34 = env26136[1];
|
|
let c31974_1 = (await getCustomActivityLinkParams(r33, r34.searchParams.get("link_id"), r34.searchParams.get("custom_id"))).customId;
|
|
handleUsePrimaryEntryPointAppCommand({
|
|
targetApplicationId: env26136[0],
|
|
channelId: c31974_0,
|
|
analyticsLocations: env26136.$parent[1],
|
|
customId: c31974_1,
|
|
referrerId: env26136[2]
|
|
});
|
|
};
|
|
r52.then(function() {
|
|
return c26137_0.apply(this, arguments);
|
|
}).catch(() => {});
|
|
r47 = true;
|
|
}
|
|
return r47;
|
|
};
|
|
}
|
|
if (r24 != null && r24.type === CodedLinkType.GUILD_PRODUCT) {
|
|
return (a0) => {
|
|
if (a0 != null) {
|
|
a0.preventDefault();
|
|
}
|
|
let [c26139_0, c26139_1] = env16348[3].code.split("-");
|
|
import("../modules/guild_products/GuildProductLinkActionCreators.native").then((result) => {
|
|
(0, result.openGuildProductLink)(c26139_0, c26139_1);
|
|
});
|
|
return true;
|
|
};
|
|
}
|
|
if (r24 != null && r24.type === CodedLinkType.SOCIAL_LAYER_STOREFRONT) {
|
|
return (a0) => {
|
|
if (a0 != null) {
|
|
a0.preventDefault();
|
|
}
|
|
const [skuId, ] = env16348[3].code.split("-");
|
|
(0, openSocialLayerStorefrontProductDetailsModal)({
|
|
skuId,
|
|
analyticsLocations: env16348[1]
|
|
});
|
|
return true;
|
|
};
|
|
}
|
|
if (r24 != null && r24.type === CodedLinkType.SOCIAL_LAYER_STOREFRONT_APP) {
|
|
return (a0) => {
|
|
if (a0 != null) {
|
|
a0.preventDefault();
|
|
}
|
|
const [skuId, ] = env16348[3].code.split("-");
|
|
(0, openSocialLayerStorefrontProductDetailsModal)({
|
|
skuId,
|
|
analyticsLocations: env16348[1]
|
|
});
|
|
return true;
|
|
};
|
|
}
|
|
if (r24 != null && r24.type === CodedLinkType.QUESTS_EMBED && getIsEligibleForQuests()) {
|
|
return (a0) => {
|
|
if (a0 != null) {
|
|
a0.preventDefault();
|
|
}
|
|
const r9 = env16348[3];
|
|
let r20 = URLUtils.toURLSafe(r9.url);
|
|
if (r20 == null) {
|
|
r20 = {};
|
|
}
|
|
const search = r20.search;
|
|
const r2 = search != null;
|
|
let filter = void 0;
|
|
let sort = void 0;
|
|
if (r2) {
|
|
const uRLSearchParams = new URLSearchParams(search);
|
|
let r28 = uRLSearchParams.get("sort");
|
|
if (r28 == null) {
|
|
r28 = void 0;
|
|
}
|
|
let r31 = uRLSearchParams.get("filter");
|
|
if (r31 == null) {
|
|
r31 = void 0;
|
|
}
|
|
filter = r31;
|
|
sort = r28;
|
|
}
|
|
if (sort == null) {
|
|
sort = null;
|
|
}
|
|
if (filter == null) {
|
|
filter = null;
|
|
}
|
|
openQuestHome({
|
|
scrollToQuestId: r9.code,
|
|
sort,
|
|
filter,
|
|
fromContent: QuestContent.QUEST_SHARE_LINK
|
|
});
|
|
return true;
|
|
};
|
|
}
|
|
if (r24 != null && r24.type === CodedLinkType.COLLECTIBLES_SHOP) {
|
|
return (a0) => {
|
|
if (a0 != null) {
|
|
a0.preventDefault();
|
|
}
|
|
const enabled = isVirtualCurrencyEnabled().enabled;
|
|
import("../modules/collectibles/CollectiblesActionCreators").then(({ openCollectiblesShopMobile }) => {
|
|
const [r8, r15] = env16348[3].code.split("-");
|
|
const r2 = r15 !== "";
|
|
const screen = enabled && r8 === CollectibleShopTab.ORBS ? CollectiblesMobileShopScreen.ORBS : r2 ? CollectiblesMobileShopScreen.SHOP_ALL : CollectiblesMobileShopScreen.FEATURED_PAGE;
|
|
const analyticsLocations = env16348[1];
|
|
openCollectiblesShopMobile({
|
|
analyticsSource: analyticsLocations[analyticsLocations.length - 1],
|
|
analyticsLocations,
|
|
screen,
|
|
initialProductSkuId: r2 ? r15 : void 0
|
|
});
|
|
});
|
|
return true;
|
|
};
|
|
}
|
|
let r86 = URLUtils.toURLSafe(a0);
|
|
if (r86 == null) {
|
|
r86 = {};
|
|
}
|
|
let host = r86.host;
|
|
let hostname = r86.hostname;
|
|
const pathname = r86.pathname;
|
|
env16348[4] = pathname;
|
|
const { search, hash } = r86;
|
|
let r90 = URLUtils.isDiscordHostname(hostname == null ? null : hostname);
|
|
if (!r90) {
|
|
if (host == null) {
|
|
host = null;
|
|
}
|
|
if (hostname == null) {
|
|
hostname = null;
|
|
}
|
|
r90 = URLUtils.isDiscordLocalhost(host, hostname);
|
|
}
|
|
if (r90 && pathname != null && (0, isGameShopPath)(pathname)) {
|
|
return (a0) => {
|
|
if (a0 != null) {
|
|
a0.preventDefault();
|
|
}
|
|
(0, openSocialLayerStorefrontUnsupportedOnMobileAlert)();
|
|
return true;
|
|
};
|
|
}
|
|
if (pathname != null && r90 && URLUtils.isAppRoute(pathname)) {
|
|
const r114 = {
|
|
navigationReplace: false,
|
|
openChannel: true
|
|
};
|
|
env16348[5] = r114;
|
|
if (search != null) {
|
|
r114.search = search;
|
|
}
|
|
if (hash != null) {
|
|
r114.hash = hash;
|
|
}
|
|
return (a0) => {
|
|
if (a0 != null) {
|
|
a0.preventDefault();
|
|
}
|
|
safeTransitionTo_native(env16348[4], env16348[5]);
|
|
return true;
|
|
};
|
|
}
|
|
if (r24 != null && r24.type === CodedLinkType.APP_OAUTH2_LINK) {
|
|
r109 = (a0) => {
|
|
if (a0 != null) {
|
|
a0.preventDefault();
|
|
}
|
|
AppAnalyticsUtils.trackWithMetadata(AnalyticEvents.APP_OAUTH2_LINK_EMBED_URL_CLICKED, {
|
|
application_id: env16348[3].code
|
|
});
|
|
openURL(env16348[0]);
|
|
return true;
|
|
};
|
|
} else {
|
|
tryParseEventDetailsPath(pathname);
|
|
r109 = skipExtensionCheck ? void 0 : isSuspiciousDownload(a0) == null ? void 0 : (a0) => {
|
|
if (a0 != null) {
|
|
a0.preventDefault();
|
|
}
|
|
SuspiciousDownloadModalActionCreators_native.show(env16348[0]);
|
|
return true;
|
|
};
|
|
}
|
|
return r109;
|
|
};
|