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

419 lines
14 KiB
TypeScript
Raw Normal View History

2026-08-25 06:04:03 +00:00
// Module ID: 9212
// Function ID: 9213
2026-07-20 16:05:17 +00:00
// Name: showInstantInviteActionSheet
2026-08-25 06:04:03 +00:00
// Dependencies: [7065, 1395, 1391, 9213, 1982, 4364, 4469, 1922, 9217, 7340, 9218, 676, 698, 7342, 9219, 9220, 4365, 4347, 9070, 4097, 7362, 5862, 4557, 38, 9215, 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-25 06:04:03 +00:00
// Module 9212 (showInstantInviteActionSheet)
2026-08-24 06:08:38 +00:00
import _modDef38 from "module_38" /* 38 */;
import expandEventPropertiesDefault from "expandEventProperties" /* 698 */;
2026-08-25 06:04:03 +00:00
import ACTION_SHEET_HEIGHT_HALFDefault from "ACTION_SHEET_HEIGHT_HALF" /* 4347 */;
import readSnowflake from "readSnowflake" /* 4365 */;
import sendSMS from "sendSMS" /* 4557 */;
import _copy from "_copy" /* 5862 */;
import _findPlayingActivity from "_findPlayingActivity" /* 7342 */;
import getInviteURLDefault from "getInviteURL" /* 7362 */;
import get_label from "get label" /* 9215 */;
import _modDef9219 from "module_9219" /* 9219 */;
import openInstantInviteActionSheetDefault from "openInstantInviteActionSheet" /* 9220 */;
import closure_3 from "handleGuildTemplateResolveSuccess" /* 7065 */;
2026-08-24 06:08:38 +00:00
import { ChannelRecordBase } from "createChannelRecord" /* 1395 */;
import closure_5 from "ensureGuildLoaded" /* 1391 */;
2026-08-25 06:04:03 +00:00
import closure_6 from "updateWithLatestInvite" /* 9213 */;
import closure_7 from "comparator" /* 1982 */;
import closure_8 from "updateInvite" /* 4364 */;
import closure_9 from "sortActivity" /* 4469 */;
2026-08-24 06:08:38 +00:00
import closure_10 from "mergeGuildAvatar" /* 1922 */;
2026-08-25 06:04:03 +00:00
import closure_11 from "getDisplayedInviteCode" /* 9217 */;
import { InviteTargetTypes } from "InviteSendStates" /* 7340 */;
import { IOS_COPY_TO_PASTEBOARD } from "SHARE_APPS_KEY" /* 9218 */;
2026-08-24 06:08:38 +00:00
import ME from "ME" /* 676 */;
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
require = arg1;
2026-07-20 16:05:17 +00:00
function showInstantInviteActionSheet(channel, source) {
2026-08-24 06:08:38 +00:00
let obj = expandEventPropertiesDefault;
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-24 06:08:38 +00:00
const streamerApplication = _findPlayingActivity.getStreamerApplication(stream, closure_9);
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-24 06:08:38 +00:00
const obj3 = _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-25 06:04:03 +00:00
tmpResult = tmp(9219);
2026-07-29 08:29:29 +00:00
tmpResult.init(channel.getGuildId(), channel.id, obj);
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
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-24 06:08:38 +00:00
openInstantInviteActionSheetDefault(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-24 06:08:38 +00:00
let obj = 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;
2026-08-24 06:08:38 +00:00
const obj2 = expandEventPropertiesDefault;
2026-07-29 08:29:29 +00:00
const tmp = require;
2026-08-24 06:08:38 +00:00
obj[3] = 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-08-24 06:08:38 +00:00
let result = require("set").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) {
2026-08-24 06:08:38 +00:00
let obj = expandEventPropertiesDefault;
2026-07-29 08:29:29 +00:00
obj = { type: "Vanity URL Invite", source: GUILD_SCHEDULED_EVENT };
obj.track(constants.OPEN_POPOUT, obj);
2026-08-25 06:04:03 +00:00
_modDef9219.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-25 06:04:03 +00:00
const obj3 = _modDef9219;
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-24 06:08:38 +00:00
openInstantInviteActionSheetDefault(obj);
2026-07-29 08:29:29 +00:00
};
2026-07-20 16:05:17 +00:00
export { trackOptionClicked };
2026-08-24 06:08:38 +00:00
export function getShareMessage(closure_10) {
return closure_10;
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-24 06:08:38 +00:00
const result = readSnowflake.parseExtraDataFromInviteKey(code);
2026-07-29 08:29:29 +00:00
const invite = store3.getInvite(result.baseCode);
2026-08-24 06:08:38 +00:00
const obj6 = 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;
2026-08-24 06:08:38 +00:00
expandEventPropertiesDefault.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-08-24 06:08:38 +00:00
const obj7 = expandEventPropertiesDefault;
2026-08-25 06:04:03 +00:00
tmp26(4347).hideAllActionSheets();
const tmp26Result = tmp26(4347);
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-25 06:04:03 +00:00
tmp21(9070).showShareActionSheet(obj, ADD_FRIENDS_WIDGET);
const tmp21Result = tmp21(9070);
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-24 06:08:38 +00:00
const result = readSnowflake.parseExtraDataFromInviteKey(code);
const obj4 = readSnowflake;
2026-07-29 08:29:29 +00:00
const tmp13 = require;
2026-08-24 06:08:38 +00:00
const tmp17 = getInviteURLDefault(code);
_copy.copy(tmp17);
2026-07-29 08:29:29 +00:00
const invite = store3.getInvite(result.baseCode);
2026-08-24 06:08:38 +00:00
const obj5 = _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;
2026-08-24 06:08:38 +00:00
expandEventPropertiesDefault.track(constants.COPY_INSTANT_INVITE, obj);
2026-07-20 16:05:17 +00:00
if (flag) {
trackOptionClicked(code, channel, constants2.COPY);
}
2026-08-24 06:08:38 +00:00
const obj6 = expandEventPropertiesDefault;
2026-08-25 06:04:03 +00:00
tmp13(4097).presentLinkCopied();
const tmp13Result = tmp13(4097);
2026-07-20 16:05:17 +00:00
}
};
2026-08-24 06:08:38 +00:00
export const handlePressSettings = function handlePressSettings(channel, closure_1, closure_3) {
closure_0 = channel;
importDefault = closure_1;
let str = closure_3;
ACTION_SHEET_HEIGHT_HALFDefault.hideActionSheet();
dependencyMap = pendingSettings.getPendingSettings();
let obj = ACTION_SHEET_HEIGHT_HALFDefault;
2026-07-20 16:05:17 +00:00
({ guild_id, id } = channel);
2026-08-24 06:08:38 +00:00
if (closure_3 == null) {
2026-07-29 08:29:29 +00:00
str = "Instant Invite Action Sheet";
2026-07-20 16:05:17 +00:00
}
2026-08-25 06:04:03 +00:00
_modDef9219.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-08-24 06:08:38 +00:00
closure_1_17(closure_0, obj);
const tmp2 = closure_1_17;
2026-07-29 08:29:29 +00:00
const tmp3 = closure_0;
2026-07-20 16:05:17 +00:00
}
});
};
2026-08-24 06:08:38 +00:00
export const isAppInstalled = function isAppInstalled(closure_3) {
return sendSMS.canOpenUrlScheme(closure_3);
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-08-24 06:08:38 +00:00
_modDef38(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-25 06:04:03 +00:00
tmp4Result = tmp4(9219);
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-25 06:04:03 +00:00
tmp4(9220)(obj);
2026-07-20 16:05:17 +00:00
}
}
2026-08-24 06:08:38 +00:00
obj1 = 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;
};