decord/source/modules/instant_invite/native/InstantInviteUtils.tsx

413 lines
14 KiB
TypeScript
Raw Normal View History

2026-08-05 07:35:12 +00:00
// Module ID: 8959
// Function ID: 8960
2026-07-20 16:05:17 +00:00
// Name: showInstantInviteActionSheet
2026-08-05 07:35:12 +00:00
// Dependencies: [6813, 1376, 1372, 8960, 1932, 4240, 4341, 1874, 8964, 7090, 8965, 676, 698, 7092, 8966, 8967, 4241, 4223, 8817, 3955, 7112, 5623, 4428, 38, 8962, 2]
2026-07-29 08:29:29 +00:00
// Exports: getShareMessage, handleCopy, handleOpenInviteActionsheet, handleOpenShareSheet, handlePressSettings, hasDeferredInvite, isAppInstalled, showInstantInviteActionSheetForChannel, showVanityUrlInviteActionSheet
2026-07-20 16:05:17 +00:00
2026-08-05 07:35:12 +00:00
// Module 8959 (showInstantInviteActionSheet)
2026-07-29 08:29:29 +00:00
import handleGuildTemplateResolveSuccess from "handleGuildTemplateResolveSuccess";
import { ChannelRecordBase } from "createChannelRecord";
import ensureGuildLoaded from "ensureGuildLoaded";
import updateWithLatestInvite from "updateWithLatestInvite";
import comparator from "comparator";
import updateInvite from "updateInvite";
import sortActivity from "sortActivity";
import mergeGuildAvatar from "mergeGuildAvatar";
import getDisplayedInviteCode from "getDisplayedInviteCode";
2026-07-23 10:11:24 +00:00
import { InviteTargetTypes } from "InviteSendStates";
import { IOS_COPY_TO_PASTEBOARD } from "SHARE_APPS_KEY";
import ME from "ME";
let closure_14;
let closure_15;
let closure_16;
const require = arg1;
2026-07-20 16:05:17 +00:00
function showInstantInviteActionSheet(channel, source) {
2026-07-29 08:29:29 +00:00
let obj = importDefault(698);
2026-07-20 16:05:17 +00:00
source = undefined;
2026-07-29 08:29:29 +00:00
if (source != null) {
2026-07-20 16:05:17 +00:00
source = source.source;
}
2026-07-29 08:29:29 +00:00
obj.track(constants.OPEN_POPOUT, { type: "Instant Invite", source });
2026-07-20 16:05:17 +00:00
let stream;
2026-07-29 08:29:29 +00:00
if (source != null) {
2026-07-20 16:05:17 +00:00
stream = source.stream;
}
2026-07-29 08:29:29 +00:00
obj = { isActionSheet: true, location: "IOS Instant Invite Action Sheet Mount" };
2026-07-20 16:05:17 +00:00
if (null != stream) {
stream = source.stream;
obj.targetType = InviteTargetTypes.STREAM;
obj.targetUserId = stream.ownerId;
2026-08-05 07:35:12 +00:00
const streamerApplication = require(7092) /* _findPlayingActivity */.getStreamerApplication(stream, sortActivity);
2026-07-29 08:29:29 +00:00
let tmpResult = tmp(698);
obj = { type: "Send Stream Invite", location: null, other_user_id: null, application_id: null, application_name: null, game_id: null };
obj[1] = obj.location;
obj[2] = stream.ownerId;
2026-07-20 16:05:17 +00:00
let id;
2026-07-29 08:29:29 +00:00
if (streamerApplication != null) {
2026-07-20 16:05:17 +00:00
id = streamerApplication.id;
}
2026-07-29 08:29:29 +00:00
obj[3] = id;
2026-07-20 16:05:17 +00:00
let name;
2026-07-29 08:29:29 +00:00
if (streamerApplication != null) {
2026-07-20 16:05:17 +00:00
name = streamerApplication.name;
}
2026-07-29 08:29:29 +00:00
obj[4] = name;
2026-07-20 16:05:17 +00:00
let id1;
2026-07-29 08:29:29 +00:00
if (streamerApplication != null) {
2026-07-20 16:05:17 +00:00
id1 = streamerApplication.id;
}
2026-07-29 08:29:29 +00:00
obj[5] = id1;
tmpResult.track(constants.OPEN_MODAL, obj);
2026-08-05 07:35:12 +00:00
const obj3 = require(7092) /* _findPlayingActivity */;
2026-07-20 16:05:17 +00:00
} else {
let targetApplicationId;
2026-07-29 08:29:29 +00:00
if (source != null) {
2026-07-20 16:05:17 +00:00
targetApplicationId = source.targetApplicationId;
}
if (null != targetApplicationId) {
obj.targetType = InviteTargetTypes.EMBEDDED_APPLICATION;
obj.targetApplicationId = source.targetApplicationId;
}
}
let createInvite;
2026-07-29 08:29:29 +00:00
if (source != null) {
2026-07-20 16:05:17 +00:00
createInvite = source.createInvite;
}
let tmp17 = false !== createInvite;
if (tmp17) {
let code;
2026-07-29 08:29:29 +00:00
if (source != null) {
2026-07-20 16:05:17 +00:00
code = source.code;
}
tmp17 = null == code;
}
if (tmp17) {
2026-08-05 07:35:12 +00:00
tmpResult = tmp(8966);
2026-07-29 08:29:29 +00:00
tmpResult.init(channel.getGuildId(), channel.id, obj);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const obj1 = { channel, source: null, guildScheduledEventId: null, targetApplicationId: null, code: null, vanityURLCode: null, stackingBehavior: null };
2026-07-20 16:05:17 +00:00
let source1;
2026-07-29 08:29:29 +00:00
if (source != null) {
2026-07-20 16:05:17 +00:00
source1 = source.source;
}
2026-07-29 08:29:29 +00:00
obj1[1] = source1;
2026-07-20 16:05:17 +00:00
let prop;
2026-07-29 08:29:29 +00:00
if (source != null) {
2026-07-20 16:05:17 +00:00
prop = source.guildScheduledEventId;
}
2026-07-29 08:29:29 +00:00
obj1[2] = prop;
2026-07-20 16:05:17 +00:00
let targetApplicationId1;
2026-07-29 08:29:29 +00:00
if (source != null) {
2026-07-20 16:05:17 +00:00
targetApplicationId1 = source.targetApplicationId;
}
2026-07-29 08:29:29 +00:00
obj1[3] = targetApplicationId1;
2026-07-20 16:05:17 +00:00
let code1;
2026-07-29 08:29:29 +00:00
if (source != null) {
2026-07-20 16:05:17 +00:00
code1 = source.code;
}
2026-07-29 08:29:29 +00:00
obj1[4] = code1;
2026-07-20 16:05:17 +00:00
let stackingBehavior;
2026-07-29 08:29:29 +00:00
if (source != null) {
2026-07-20 16:05:17 +00:00
stackingBehavior = source.stackingBehavior;
}
2026-07-29 08:29:29 +00:00
obj1[6] = stackingBehavior;
2026-08-05 07:35:12 +00:00
importDefault(8967)(obj1);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
function trackOptionClicked(code, channel, COPY, _location) {
2026-08-05 07:35:12 +00:00
let obj = require(4241) /* readSnowflake */;
2026-07-29 08:29:29 +00:00
const invite = store3.getInvite(obj.parseExtraDataFromInviteKey(code).baseCode);
obj = { invite_type: COPY, guild_id: null, channel_id: null, invite_code: null, invite_channel_type: null, invite_inviter_id: null, location: null, application_id: null };
if (channel instanceof ChannelRecordBase) {
let guild_id = channel.guild_id;
2026-07-20 16:05:17 +00:00
} else {
let id;
2026-07-29 08:29:29 +00:00
if (channel != null) {
id = channel.id;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
channel = store.getChannel(id);
if (channel != null) {
2026-07-20 16:05:17 +00:00
guild_id = channel.getGuildId();
}
}
2026-07-29 08:29:29 +00:00
obj[1] = guild_id;
let id1;
if (channel != null) {
id1 = channel.id;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj[2] = id1;
const obj2 = importDefault(698);
const tmp = require;
2026-08-05 07:35:12 +00:00
obj[3] = require(4241) /* readSnowflake */.parseInviteCodeFromInviteKey(code);
2026-07-20 16:05:17 +00:00
let type;
2026-07-29 08:29:29 +00:00
if (channel != null) {
2026-07-20 16:05:17 +00:00
type = channel.type;
}
2026-07-29 08:29:29 +00:00
obj[4] = type;
2026-07-20 16:05:17 +00:00
const currentUser = authStore.getCurrentUser();
let id2;
2026-07-29 08:29:29 +00:00
if (currentUser != null) {
id2 = currentUser.id;
}
obj[5] = id2;
obj[6] = _location;
let id3;
if (invite != null) {
2026-07-20 16:05:17 +00:00
const target_application = invite.target_application;
2026-07-29 08:29:29 +00:00
if (target_application != null) {
id3 = target_application.id;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
obj[7] = id3;
2026-07-20 16:05:17 +00:00
obj2.track(constants.INSTANT_INVITE_OPTION_CLICKED, obj);
}
2026-07-23 10:11:24 +00:00
({ AnalyticEvents: closure_14, InviteOptionsType: closure_15, Permissions: closure_16 } = ME);
2026-07-29 08:29:29 +00:00
let result = require("ensureGuildLoaded").fileFinishedImporting("modules/instant_invite/native/InstantInviteUtils.tsx");
2026-07-20 16:05:17 +00:00
export const showInstantInviteActionSheetForChannel = function showInstantInviteActionSheetForChannel(channelId) {
2026-07-29 08:29:29 +00:00
const channel = store.getChannel(channelId);
2026-07-20 16:05:17 +00:00
if (null != channel) {
showInstantInviteActionSheet(channel);
}
};
export { showInstantInviteActionSheet };
2026-07-29 08:29:29 +00:00
export const showVanityUrlInviteActionSheet = function showVanityUrlInviteActionSheet(guild, channel, GUILD_SCHEDULED_EVENT, guildScheduledEventId) {
let obj = importDefault(698);
obj = { type: "Vanity URL Invite", source: GUILD_SCHEDULED_EVENT };
obj.track(constants.OPEN_POPOUT, obj);
2026-08-05 07:35:12 +00:00
importDefault(8966).init(guild.id, channel.id, { skipCreateInvite: true });
2026-07-29 08:29:29 +00:00
obj = { vanityURLCode: guild.vanityURLCode, channel, source: GUILD_SCHEDULED_EVENT, guildScheduledEventId: null, stackingBehavior: null };
let prop;
2026-08-05 07:35:12 +00:00
const obj3 = importDefault(8966);
2026-07-29 08:29:29 +00:00
if (guildScheduledEventId != null) {
prop = guildScheduledEventId.guildScheduledEventId;
}
obj[3] = prop;
let stackingBehavior;
if (guildScheduledEventId != null) {
stackingBehavior = guildScheduledEventId.stackingBehavior;
}
obj[4] = stackingBehavior;
2026-08-05 07:35:12 +00:00
importDefault(8967)(obj);
2026-07-29 08:29:29 +00:00
};
2026-07-20 16:05:17 +00:00
export { trackOptionClicked };
2026-07-23 10:11:24 +00:00
export function getShareMessage(c10) {
return c10;
2026-07-20 16:05:17 +00:00
}
export const handleOpenShareSheet = function handleOpenShareSheet(code, channel, intl, ADD_FRIENDS_WIDGET) {
let flag = arg4;
if (arg4 === undefined) {
flag = true;
}
if (null != code) {
2026-08-05 07:35:12 +00:00
const result = require(4241) /* readSnowflake */.parseExtraDataFromInviteKey(code);
2026-07-29 08:29:29 +00:00
const invite = store3.getInvite(result.baseCode);
2026-08-05 07:35:12 +00:00
const obj6 = require(4241) /* readSnowflake */;
2026-07-29 08:29:29 +00:00
const tmp21 = require;
const tmp26 = importDefault;
if (channel instanceof ChannelRecordBase) {
let guild_id = channel.guild_id;
} else {
let id;
if (channel != null) {
id = channel.id;
}
channel = store.getChannel(id);
if (channel != null) {
guild_id = channel.getGuildId();
}
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let obj = { guild_id: null, channel_id: null, invite_code: null, invite_channel_type: null, invite_inviter_id: null, invite_guild_scheduled_event_id: null, location: null, application_id: null };
obj[0] = guild_id;
let id1;
if (channel != null) {
id1 = channel.id;
}
obj[1] = id1;
obj[2] = result.baseCode;
2026-07-20 16:05:17 +00:00
let type;
2026-07-29 08:29:29 +00:00
if (channel != null) {
2026-07-20 16:05:17 +00:00
type = channel.type;
}
2026-07-29 08:29:29 +00:00
obj[3] = type;
2026-07-20 16:05:17 +00:00
const currentUser = authStore.getCurrentUser();
let id2;
2026-07-29 08:29:29 +00:00
if (currentUser != null) {
id2 = currentUser.id;
}
obj[4] = id2;
obj[5] = result.guildScheduledEventId;
obj[6] = ADD_FRIENDS_WIDGET;
let id3;
if (invite != null) {
2026-07-20 16:05:17 +00:00
const target_application = invite.target_application;
2026-07-29 08:29:29 +00:00
if (target_application != null) {
id3 = target_application.id;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
obj[7] = id3;
importDefault(698).track(constants.INSTANT_INVITE_SHARED, obj);
2026-07-20 16:05:17 +00:00
if (flag) {
trackOptionClicked(code, channel, constants2.SHARE, ADD_FRIENDS_WIDGET);
}
2026-07-29 08:29:29 +00:00
const obj7 = importDefault(698);
2026-08-05 07:35:12 +00:00
tmp26(4223).hideAllActionSheets();
const tmp26Result = tmp26(4223);
2026-07-29 08:29:29 +00:00
obj = { message: null, iOSOnlyShareCallback: null };
obj[0] = intl;
obj[1] = function iOSOnlyShareCallback(arg0, arr) {
let tmp = arg0;
if (arg0) {
tmp = null != arr;
}
if (tmp) {
tmp = !arr.includes(closure_13);
}
if (tmp) {
callback(table[19]).presentInviteSent();
const obj = callback(table[19]);
}
2026-07-20 16:05:17 +00:00
};
2026-08-05 07:35:12 +00:00
tmp21(8817).showShareActionSheet(obj, ADD_FRIENDS_WIDGET);
const tmp21Result = tmp21(8817);
2026-07-20 16:05:17 +00:00
}
};
export const handleCopy = function handleCopy(code, channel, GROUP_DM, arg3) {
let flag = arg3;
if (arg3 === undefined) {
flag = true;
}
if (null != code) {
2026-08-05 07:35:12 +00:00
const result = require(4241) /* readSnowflake */.parseExtraDataFromInviteKey(code);
const obj4 = require(4241) /* readSnowflake */;
2026-07-29 08:29:29 +00:00
const tmp13 = require;
2026-08-05 07:35:12 +00:00
const tmp17 = importDefault(7112)(code);
require(5623) /* _copy */.copy(tmp17);
2026-07-29 08:29:29 +00:00
const invite = store3.getInvite(result.baseCode);
2026-08-05 07:35:12 +00:00
const obj5 = require(5623) /* _copy */;
2026-07-29 08:29:29 +00:00
if (channel instanceof ChannelRecordBase) {
let guild_id = channel.guild_id;
} else {
let id;
if (channel != null) {
id = channel.id;
}
channel = store.getChannel(id);
if (channel != null) {
guild_id = channel.getGuildId();
}
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const obj = { server: null, channel: null, channel_type: null, location: null, code: null, guild_scheduled_event_id: null, application_id: null };
obj[0] = guild_id;
let id1;
if (channel != null) {
id1 = channel.id;
}
obj[1] = id1;
2026-07-20 16:05:17 +00:00
let type;
2026-07-29 08:29:29 +00:00
if (channel != null) {
2026-07-20 16:05:17 +00:00
type = channel.type;
}
2026-07-29 08:29:29 +00:00
obj[2] = type;
obj[3] = GROUP_DM;
({ baseCode: obj2[4], guildScheduledEventId: obj2[5] } = result);
let id2;
if (invite != null) {
2026-07-20 16:05:17 +00:00
const target_application = invite.target_application;
2026-07-29 08:29:29 +00:00
if (target_application != null) {
id2 = target_application.id;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
obj[6] = id2;
importDefault(698).track(constants.COPY_INSTANT_INVITE, obj);
2026-07-20 16:05:17 +00:00
if (flag) {
trackOptionClicked(code, channel, constants2.COPY);
}
2026-07-29 08:29:29 +00:00
const obj6 = importDefault(698);
2026-08-05 07:35:12 +00:00
tmp13(3955).presentLinkCopied();
const tmp13Result = tmp13(3955);
2026-07-20 16:05:17 +00:00
}
};
2026-07-29 08:29:29 +00:00
export const handlePressSettings = function handlePressSettings(channel, closure_1, handleGuildTemplateResolveSuccess) {
2026-07-20 16:05:17 +00:00
let guild_id;
let id;
2026-07-23 10:11:24 +00:00
let closure_0 = channel;
2026-07-20 16:05:17 +00:00
const importDefault = closure_1;
2026-07-29 08:29:29 +00:00
let str = handleGuildTemplateResolveSuccess;
2026-08-05 07:35:12 +00:00
importDefault(4223).hideActionSheet();
2026-07-23 10:11:24 +00:00
const dependencyMap = pendingSettings.getPendingSettings();
2026-08-05 07:35:12 +00:00
let obj = importDefault(4223);
2026-07-20 16:05:17 +00:00
({ guild_id, id } = channel);
2026-07-29 08:29:29 +00:00
if (handleGuildTemplateResolveSuccess == null) {
str = "Instant Invite Action Sheet";
2026-07-20 16:05:17 +00:00
}
2026-08-05 07:35:12 +00:00
importDefault(8966).openSettings(guild_id, id, str, () => {
2026-07-29 08:29:29 +00:00
if (null != closure_1) {
tmp();
2026-07-20 16:05:17 +00:00
} else {
let targetApplicationId;
2026-07-29 08:29:29 +00:00
if (targetApplicationId != null) {
2026-07-20 16:05:17 +00:00
targetApplicationId = targetApplicationId.targetApplicationId;
}
2026-07-29 08:29:29 +00:00
const obj = { createInvite: false, targetApplicationId: null };
obj[1] = targetApplicationId;
2026-07-23 10:11:24 +00:00
outer1_17(closure_0, obj);
2026-07-29 08:29:29 +00:00
const tmp2 = outer1_17;
const tmp3 = closure_0;
2026-07-20 16:05:17 +00:00
}
});
};
2026-07-29 08:29:29 +00:00
export const isAppInstalled = function isAppInstalled(handleGuildTemplateResolveSuccess) {
2026-08-05 07:35:12 +00:00
return require(4428) /* sendSMS */.canOpenUrlScheme(handleGuildTemplateResolveSuccess);
2026-07-20 16:05:17 +00:00
};
export const handleOpenInviteActionsheet = function handleOpenInviteActionsheet(guild, id, channels, GUILD_HEADER) {
2026-07-29 08:29:29 +00:00
let obj = store;
let channel = store.getChannel(id);
if (channel == null) {
channel = store2.getDefaultChannel(guild.id, true, constants3.CREATE_INSTANT_INVITE);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
importDefault(38)(null != channel, "Channel cannot be null");
2026-07-20 16:05:17 +00:00
if (null != guild.vanityURLCode) {
if ("" !== guild.vanityURLCode) {
2026-07-29 08:29:29 +00:00
let tmp4Result = tmp4(698);
obj = { type: "Vanity URL Invite", source: null };
obj[1] = GUILD_HEADER;
tmp4Result.track(constants.OPEN_POPOUT, obj);
2026-08-05 07:35:12 +00:00
tmp4Result = tmp4(8966);
2026-07-29 08:29:29 +00:00
tmp4Result.init(guild.id, channel.id, { skipCreateInvite: true });
obj = { vanityURLCode: null, channel: null, source: null, guildScheduledEventId: null, stackingBehavior: null };
obj[0] = guild.vanityURLCode;
obj[1] = channel;
obj[2] = GUILD_HEADER;
obj[3] = undefined;
obj[4] = undefined;
2026-08-05 07:35:12 +00:00
tmp4(8967)(obj);
2026-07-20 16:05:17 +00:00
}
}
2026-08-05 07:35:12 +00:00
let obj1 = require(8962) /* get label */;
2026-07-29 08:29:29 +00:00
const inviteChannelId = obj1.getInviteChannelId(channel.id, channels);
2026-07-20 16:05:17 +00:00
if (null != inviteChannelId) {
2026-07-29 08:29:29 +00:00
let channel1 = obj.getChannel(inviteChannelId);
if (channel1 == null) {
channel1 = store2.getDefaultChannel(guild.id, true, constants3.CREATE_INSTANT_INVITE);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp4(38)(null != channel1, "Channel cannot be null");
obj1 = { source: null };
obj1[0] = GUILD_HEADER;
showInstantInviteActionSheet(channel1, obj1);
2026-07-20 16:05:17 +00:00
}
};
export const hasDeferredInvite = function hasDeferredInvite() {
2026-07-23 10:11:24 +00:00
displayedInviteCode = displayedInviteCode.getDisplayedInviteCode();
2026-07-29 08:29:29 +00:00
displayedGuildTemplateCode = displayedGuildTemplateCode.getDisplayedGuildTemplateCode();
2026-07-20 16:05:17 +00:00
let invite = null;
if (null != displayedInviteCode) {
2026-07-29 08:29:29 +00:00
invite = store3.getInvite(displayedInviteCode);
2026-07-20 16:05:17 +00:00
}
let guildTemplate = null;
if (null != displayedGuildTemplateCode) {
2026-07-29 08:29:29 +00:00
guildTemplate = displayedGuildTemplateCode.getGuildTemplate(displayedGuildTemplateCode);
2026-07-20 16:05:17 +00:00
}
return null != invite || null != guildTemplate;
};