Files
discord-decomp/actions/InstantInviteActionCreators.tsx
T
2026-11-01 12:12:55 +02:00

1201 lines
40 KiB
TypeScript

// Metro module 6693 (f6694).
import "../modules/gateway/PostConnectionCallbackStore";
import GuildScheduledEventStore, { isGuildScheduledEventActive } from "../modules/guild_scheduled_events/GuildScheduledEventStore";
import { isGuildTextChannelType } from "../records/ChannelRecord";
import AuthenticationStore from "../stores/AuthenticationStore";
import ChannelStore from "../stores/ChannelStore";
import "../stores/GuildChannelStore";
import "../stores/GuildMemberStore";
import GuildStore from "../stores/GuildStore";
import InstantInviteStore from "../stores/InstantInviteStore";
import InviteStore from "../stores/InviteStore";
import "../stores/PermissionStore";
import RelationshipStore from "../stores/RelationshipStore";
import "../stores/SelectedGuildStore";
import UserStore from "../stores/UserStore";
import { AnalyticEvents, Endpoints, UserFlags, AbortCodes, GuildFeatures, RPCCommands, Routes } from "../Constants";
import { AgeGateSource } from "../modules/age_gate/AgeGateConstants";
import "../modules/channel/ChannelConstants";
import "../modules/go_live/Constants";
import { InviteTargetTypes } from "../modules/instant_invite/Constants";
import "../modules/stage_channels/StageChannelsConstants";
import * as _Module1384 from "../_bundle/Module1384";
import { GuildInviteFlags } from "../_bundle/Module6709";
import * as _router_utils from "../modules/routing/router_utils";
import Dispatcher from "../Dispatcher";
import resolveInvite2 from "../modules/instant_invite/resolveInvite";
import GuildActionCreators from "./GuildActionCreators";
import AnalyticsUtils from "../utils/AnalyticsUtils";
import { HTTP, rejectWithMigratedError } from "../_bundle/sendRequest";
import APIError from "../errors/APIError";
import Durations from "../utils/Durations";
import TrackedHTTPUtils from "../utils/TrackedHTTPUtils";
import { NetworkActionNames } from "../_bundle/Module503";
import { exact } from "../_bundle/Module1385";
import { parseInviteCodeFromInviteKey, parseExtraDataFromInviteKey, generateInviteKeyFromExtraData, getInviteKeySearchSuffix } from "../modules/instant_invite/InviteCodeUtils";
import openQuarantineModeInfoModal_native from "../modules/quarantine/openQuarantineModeInfoModal.native";
import { openAgeGateModal } from "../modules/age_gate/AgeGateModalActionCreators";
import V6OrEarlierAPIError from "../errors/V6OrEarlierAPIError";
import HubUtils_native from "../modules/hub/HubUtils.native";
import { inviteGuildHasPendingMemberDisabledVerification, openVerificationModalOrTransitionToApplication } from "../modules/guild_verification/GuildVerificationUtils";
import CodedLinkActionCreators from "../modules/coded_links/web/CodedLinkActionCreators";
import Module4508 from "../_bundle/Module4508";
import { isTablet } from "../_bundle/Module4426";
import { getInviteDynamicLinkTemplate, getDefaultDynamicLinkTemplate } from "../_bundle/Module12426";
import generateDynamicLink from "../_bundle/generateDynamicLink";
import ProtocolUtils from "../utils/web/ProtocolUtils";
import { HermesBuiltin } from "../_hermes/prelude";
function $mk78931($env) {
return () => {
let r40, channelId, id;
const r6 = $env;
const r7 = $env.$parent;
const r12 = r7[14];
const r14 = r6[0];
const channel2 = r12.getChannel(r14);
const currentUser = r7[23].getCurrentUser();
let r4 = channel2 == null || currentUser == null;
if (!r4) {
const r25 = channel2.nsfw && !currentUser.nsfwAllowed || channel2.isGuildVocalOrThread() && (0, r7[0])(r7[3][41]).maybeOpenAgeGateForVoiceChannel(r14) || channel2.isGuildVocalOrThread() && (0, r7[0])(r7[3][42]).maybeOpenSpoilerGateForVoiceChannel(r14);
L95: {
r40 = !r25;
if (!r25) {
const r41 = r6[1];
if (r41?.guildScheduledEvent != null) {
let env25960 = {
$parent: r7
};
const guildScheduledEvent3 = r41.guildScheduledEvent;
env25960[0] = guildScheduledEvent3;
env25960[1] = r41.welcomeModalChannelId;
const r191 = guildScheduledEvent3 != null;
r40 = false;
if (r191) {
(0, r7[5])(() => {
const r3 = env25960[0];
const r4 = {
guildScheduledEventId: r3.id
};
const welcomeModalChannelId = env25960[1];
if (welcomeModalChannelId != null) {
r4.welcomeModalChannelId = welcomeModalChannelId;
}
const r6 = env25960.$parent;
(0, r6[0])(r6[3][38]).transitionToEventDetailsFromInvite(r3, r4);
});
r40 = false;
}
} else {
let r44 = channel2.getGuildId();
if (r44 == null) {
r44 = r7[27];
}
let analyticsLocations2 = r6[2];
let env25959 = {
$parent: r7
};
env25959[0] = r44;
env25959[1] = channel2;
env25959[2] = r41;
if (analyticsLocations2 === void 0) {
analyticsLocations2 = [];
}
env25959[3] = analyticsLocations2;
env25959[4] = void 0;
env25959[5] = void 0;
env25959[6] = void 0;
env25959[7] = void 0;
env25959[8] = void 0;
env25959[9] = void 0;
env25959[10] = void 0;
const guild = r7[17].getGuild(r44);
const r50 = guild == null ? void 0 : guild.features.has(r7[29].MEMBER_VERIFICATION_MANUAL_APPROVAL);
const r54 = r41 == null ? {} : r41;
env25959[4] = r54.targetUserId;
const targetType = r54.targetType;
env25959[5] = targetType;
const targetApplicationId = r54.targetApplicationId;
env25959[6] = targetApplicationId;
const isGuestInvite = r54.isGuestInvite;
env25959[7] = isGuestInvite;
const isApplicationBypassInvite = r54.isApplicationBypassInvite;
if (!isGuestInvite && !isApplicationBypassInvite && !r41?.forceTransition && r50) {
const guildId = r7[22].getGuildId();
r40 = false;
if (guildId !== r44) {
break L95;
}
}
const type = channel2.type;
const channel4 = r12.getChannel(channel2.id);
const targetChannelId = r41?.targetChannelId;
L51: {
if (targetChannelId != null) {
const channel3 = r12.getChannel(targetChannelId);
if (channel3 != null) {
const r72 = r7[20].can((0, r7[12])(channel3.type), channel3);
channelId = targetChannelId;
if (r72) {
break L51;
}
}
}
if (r41?.targetType == null && (!(0, r7[9])(channel2.type) && (0, r7[0])(r7[3][23]).canSeeOnboardingHome(r44))) {
channelId = r7[35].GUILD_HOME;
} else {
const channel5 = r12.getChannel(channel2.id);
if (r7[20].can((0, r7[12])(channel2.type), channel5)) {
id = channel2.id;
} else {
id = r7[15].getDefaultChannel(r44, true, r7[32].CREATE_INSTANT_INVITE)?.id;
if (id == null) {
id = channel2.id;
}
}
channelId = id;
}
}
env25959[8] = channelId;
const r103 = r7[25];
env25959[9] = type === r103.GUILD_STAGE_VOICE;
const r108 = r41?.targetChannelId != null && channelId === r41.targetChannelId;
const r110 = r108 ? r41?.targetMessageId : void 0;
const r112 = r7[26];
const r114 = r112.CHANNEL(r44, channelId, r110);
env25959[10] = r114;
if (channelId === channel2.id && (0, r7[9])(type) && r41?.autoJoin !== false) {
(0, r7[5])(() => {
const r1 = env25959.$parent;
const r3 = r1[0];
const r4 = r1[3];
r3(r4[27])(r4[26], r4.paths).then(({ default: default2 }) => {
const connect = () => {
if (env25959[9]) {
const r75 = env25959.$parent;
const r80 = (0, r75[0])(r75[3][28]);
const r82 = env25959[1];
r80.connectAndOpen(r82 instanceof r75[11] ? r82 : (0, r75[10])(r82));
(0, r75[0])(r75[3][25]).transitionTo(env25959[10]);
return void 0;
}
const r9 = env25959[2];
if (r9?.muteOnJoinVoiceChannel) {
const r15 = env25959.$parent;
(0, r15[1])(r15[3][29]).setSelfMute((0, r15[0])(r15[3][30]).MediaEngineContextTypes.DEFAULT, true);
}
const channelId = env25959[8];
default2.selectVoiceChannel(channelId);
const r31 = env25959[5];
const r32 = env25959.$parent;
const r33 = r32[37];
if (r31 === r33.STREAM && env25959[4] != null) {
(0, r32[2])(r32[3][31]).watchStreamAndTransitionToStream({
streamType: r32[36].GUILD,
ownerId: env25959[4],
guildId: env25959[0],
channelId
});
}
if (r31 === r33.EMBEDDED_APPLICATION && env25959[6] != null) {
const r50 = (0, r32[0])(r32[3][25]);
const r52 = r32[26];
let r54 = env25959[0];
if (r54 == null) {
r54 = r32[27];
}
r50.transitionTo(r52.CHANNEL(r54, channelId));
(0, r32[1])(r32[3][32])({
channelId,
applicationId: env25959[6],
intent: r9?.intent,
inviterUserId: r9?.inviterUserId,
analyticsLocations: env25959[3],
commandOrigin: (0, r32[0])(r32[3][33]).CommandOrigin.CHAT
});
}
};
if (!env25959[7]) {
const r8 = env25959.$parent;
const r3 = r8[0];
const r13 = r8[3];
const r7 = r3(r13[34]);
const r14 = env25959[0];
if (r7.shouldShowMembershipVerificationGate(r14, [r8[17], r8[23], r8[16]])) {
r3(r13[35]).openMemberVerificationModal(r14, connect);
} else {
connect();
}
} else {
connect();
}
});
});
} else {
const r121 = r7[0];
const r122 = r7[3];
if (r121(r122[36]).isActivityInTextSupportedForChannel(channel4) && targetType === r7[37].EMBEDDED_APPLICATION && targetApplicationId != null) {
const r130 = r121(r122[25]);
let r133 = r44;
if (r133 == null) {
r133 = r7[27];
}
r130.transitionTo(r112.CHANNEL(r133, channelId));
(0, r7[1])(r122[32])({
channelId,
applicationId: targetApplicationId,
intent: r41?.intent,
inviterUserId: r41?.inviterUserId,
analyticsLocations: analyticsLocations2,
commandOrigin: r121(r122[33]).CommandOrigin.CHAT
});
}
}
if (r108 && r44 !== r7[27]) {
const runDeepLinkJump = function runDeepLinkJump() {
const r5 = env25959[1];
let r3 = env25959[2];
const type = r5.type;
if (r3 == null) {
r3 = {};
}
const r7 = env25959.$parent;
const { transitionTo, welcomeModalChannelId, guildScheduledEvent: guildScheduledEvent2 } = r3;
const GUILD_STAGE_VOICE = r7[25].GUILD_STAGE_VOICE;
const r13 = r7[1];
const r15 = r7[3];
const r18 = {
source: r13(r15[24]).INVITE_ACCEPT,
navigationReplace: true,
openChannel: true
};
if (welcomeModalChannelId != null) {
r18.welcomeModalChannelId = welcomeModalChannelId;
}
if (type === GUILD_STAGE_VOICE) {
r18.state = {
stageInviteKey: r7[38]
};
}
if (guildScheduledEvent2 != null) {
r18.guildScheduledEventId = guildScheduledEvent2.id;
}
const r22 = env25959[10];
return transitionTo != null ? transitionTo(r22, r18) : (0, r7[0])(r15[25]).transitionTo(r22, r18);
};
const r176 = r7[0];
const r177 = r7[3];
r176(r177[27])(r177[37], r177.paths).then((result) => (0, result.default)({
guildId: env25959[0]
})).then(runDeepLinkJump, runDeepLinkJump);
r40 = false;
break L95;
}
const type2 = channel2.type;
let r154 = r41;
if (r154 == null) {
r154 = {};
}
const { transitionTo, welcomeModalChannelId, guildScheduledEvent: guildScheduledEvent2 } = r154;
const GUILD_STAGE_VOICE = r103.GUILD_STAGE_VOICE;
const r159 = r7[1];
const r160 = r7[3];
const r164 = {
source: r159(r160[24]).INVITE_ACCEPT,
navigationReplace: true
};
if (r108) {
r164.openChannel = true;
}
if (welcomeModalChannelId != null) {
r164.welcomeModalChannelId = welcomeModalChannelId;
}
if (type2 === GUILD_STAGE_VOICE) {
r164.state = {
stageInviteKey: r7[38]
};
}
if (guildScheduledEvent2 != null) {
r164.guildScheduledEventId = guildScheduledEvent2.id;
}
if (transitionTo != null) {
transitionTo(r114, r164);
r40 = false;
} else {
(0, r7[0])(r160[25]).transitionTo(r114, r164);
r40 = false;
}
}
}
}
r4 = r40;
}
return r4;
};
}
function $mk78933($env) {
return () => {
let r23;
let env25962;
const r2 = $env;
const r1 = $env.$parent;
const code3 = r2[0];
const r5 = r2[1];
const r4 = r2[2];
const r11 = env25962 = {
$parent: r1
};
env25962[0] = code3;
env25962[1] = r5;
env25962[2] = r4;
const r7 = r1[1];
const r3 = r1[3];
if (r7(r3[39]).isDispatching()) {
r23 = Promise.resolve().then($mk78933(r11));
} else {
r7(r3[39]).dispatch({
type: "INVITE_RESOLVE",
code: code3
});
r23 = r7(r3[40])(code3, r5, r4).then($mk78934(r1));
}
return r23;
};
}
function $mk78934($env) {
return (a0) => {
const r1 = $env;
const { invite, code: code3, banned } = a0;
if (invite != null) {
(0, r1[1])(r1[3][39]).dispatch({
type: "INVITE_RESOLVE_SUCCESS",
invite,
code: code3
});
} else {
(0, r1[1])(r1[3][39]).dispatch({
type: "INVITE_RESOLVE_FAILURE",
code: code3,
banned
});
}
return {
invite,
code: code3
};
};
}
let transitionToInviteChannelSync, c4292_39, c4292_40;
let env4292 = {};
const generateAcceptInviteOptions = function generateAcceptInviteOptions(a0) {
const r4 = {};
const target_type = a0.target_type;
if (InviteTargetTypes.STREAM === target_type) {
r4.targetType = a0.target_type;
r4.targetUserId = a0.target_user?.id;
} else if (InviteTargetTypes.EMBEDDED_APPLICATION === target_type) {
r4.targetType = a0.target_type;
r4.targetApplicationId = a0.target_application?.id;
} else if (InviteTargetTypes.ROLE_SUBSCRIPTIONS_PURCHASE === target_type) {
r4.targetType = a0.target_type;
}
const r31 = !(GuildStore.getGuild(a0.guild?.id) != null) || a0.new_member;
if (r31 && a0.channel != null && (0, isGuildTextChannelType)(a0.channel.type)) {
r4.welcomeModalChannelId = a0.channel.id;
}
if (a0.guild_scheduled_event != null) {
r4.guildScheduledEvent = a0.guild_scheduled_event;
}
let flags2 = a0.flags;
if (flags2 == null) {
flags2 = 0;
}
r4.isGuestInvite = _Module1384.hasFlag(flags2, GuildInviteFlags.IS_GUEST_INVITE);
let flags3 = a0.flags;
if (flags3 == null) {
flags3 = 0;
}
r4.isApplicationBypassInvite = _Module1384.hasFlag(flags3, GuildInviteFlags.IS_APPLICATION_BYPASS);
r4.inviterUserId = a0.inviter?.id;
if (!r31) {
r4.forceTransition = true;
}
if (a0.target_channel_id != null) {
r4.targetChannelId = a0.target_channel_id;
if (a0.target_message_id != null) {
r4.targetMessageId = a0.target_message_id;
}
}
return r4;
};
transitionToInviteChannelSync = function transitionToInviteChannelSync(a0, a1) {
let env15850;
const r1 = env15850 = {
$parent: env4292
};
env15850[0] = a0;
env15850[2] = void 0 === void 0 ? [] : void 0;
ChannelStore.addConditionalChangeListener($mk78931(r1));
};
export function trackInviteServerClicked(a0, a1, a2) {
let location_stack = a2;
const INVITE_SERVER_CLICKED = AnalyticEvents.INVITE_SERVER_CLICKED;
if (a2 == null) {
location_stack = null;
}
AnalyticsUtils.track(INVITE_SERVER_CLICKED, {
guild_id: a0,
action: a1,
location_stack
});
}
c4292_39 = "invite";
c4292_40 = null;
const r86 = {
resolveInvite: function resolveInvite(a0, a1, a2) {
let r22;
let env15851;
const r1 = env4292;
const r2 = env15851 = {
$parent: env4292
};
env15851[0] = a0;
env15851[1] = a1;
env15851[2] = a2;
if (Dispatcher.isDispatching()) {
r22 = Promise.resolve().then($mk78933(r2));
} else {
Dispatcher.dispatch({
type: "INVITE_RESOLVE",
code: a0
});
r22 = resolveInvite2(a0, a1, a2).then($mk78934(r1));
}
return r22;
},
getInviteContext: (a0, a1) => ({
location: a0,
location_guild_id: a1?.guild != null ? a1.guild.id : void 0,
location_channel_id: a1?.channel != null ? a1.channel.id : void 0,
location_channel_type: a1?.channel != null ? a1.channel.type : void 0
}),
createInvite: async function createInvite(c15852_0, r3 = {}) {
let r81;
let c15852_1 = r3;
const location2 = arguments[2];
let c25963_2;
let c25963_3 = 0;
let c29824_0, c29824_1;
try {
c29824_0 = void 0;
c25963_3 = 1;
const body = {
...c15852_1
};
if (body.role_ids?.length === 0) {
delete body["role_ids"];
}
c29824_0 = (await HTTP.post({
url: Endpoints.INSTANT_INVITES(c15852_0),
body,
context: {
location: location2
},
rejectWithError: true
})).body;
Dispatcher.dispatch({
type: "INSTANT_INVITE_CREATE_SUCCESS",
channelId: c15852_0,
invite: c29824_0
});
r81 = c29824_0;
c25963_3 = 0;
} catch ($e) {
const r33 = $e;
let r11 = r33;
c25963_2 = r33;
if (c25963_3 !== 0) {
while (true) {
try {
const r90 = c25963_2;
c25963_3 = 0;
c29824_1 = r90;
Dispatcher.dispatch({
type: "INSTANT_INVITE_CREATE_FAILURE",
channelId: c15852_0
});
throw new APIError(c29824_1);
} catch (r86) {
r11 = r86;
c25963_2 = r86;
if (c25963_3 === 0) {
break;
}
}
}
}
throw r11;
}
return r81;
},
mobileCreateInvite: async function mobileCreateInvite(c15853_0, c15853_1) {
let r67, code3;
const _this = this;
let c25964_0;
L15: {
L10: {
let env29825;
const r11 = env29825 = {
$parent: env4292
};
c25964_0 = r11;
env29825[0] = void 0;
const invite = InstantInviteStore.getInvite(c15853_0.id);
if (invite != null && !invite.isExpired()) {
code3 = invite.code;
break L10;
}
env29825[0] = await _this.createInvite(c15853_0.id, {
max_age: Durations.Seconds.DAY
}, c15853_1).catch(() => Dispatcher.dispatch({
type: "NATIVE_APP_INSTANT_INVITE_GDM_SHARE_FAILED"
}));
const r64 = env29825[0];
const r66 = r64 == null;
r67 = void 0;
if (r66) {
break L15;
}
r67 = r64.code;
break L15;
}
return code3;
}
return r67;
},
getAllFriendInvites: async (c15854_0) => {
let r126;
let c25965_0, c25965_1;
L17: {
let env29826;
c25965_1 = void 0;
const r11 = env29826 = {
$parent: env4292
};
c25965_0 = r11;
env29826[0] = void 0;
await new Promise((c31432_0) => Dispatcher.wait(() => c31432_0(null)));
if (InstantInviteStore.getFriendInvitesFetching()) {
if (c4292_40 != null) {
r126 = c4292_40.then((result) => result.body);
break L17;
}
r126 = Promise.reject(new Error("Invalid friend invite fetch request"));
break L17;
}
env4292[40] = HTTP.get({
url: Endpoints.FRIEND_INVITES,
context: {
location: c15854_0
},
rejectWithError: rejectWithMigratedError()
});
Dispatcher.dispatch({
type: "FRIEND_INVITES_FETCH_REQUEST",
requestedAt: new Date()
});
env29826[0] = (await c4292_40).body;
env4292[40] = null;
Dispatcher.dispatch({
type: "FRIEND_INVITES_FETCH_RESPONSE",
receivedAt: new Date(),
invites: env29826[0]
});
return env29826[0];
}
return r126;
},
createFriendInvite: (a0, a1) => {
let body = a0;
Dispatcher.dispatch({
type: "FRIEND_INVITE_CREATE_REQUEST"
});
if (a0 == null) {
body = {};
}
return HTTP.post({
url: Endpoints.FRIEND_INVITES,
body,
context: {
location: a1
},
rejectWithError: rejectWithMigratedError()
}).then(({ body }) => {
Dispatcher.dispatch({
type: "FRIEND_INVITE_CREATE_SUCCESS",
invite: body
});
return body;
}, (a0) => {
Dispatcher.dispatch({
type: "FRIEND_INVITE_CREATE_FAILURE",
error: a0
});
throw a0;
});
},
revokeFriendInvites: () => {
Dispatcher.dispatch({
type: "FRIEND_INVITE_REVOKE_REQUEST"
});
return HTTP.del({
url: Endpoints.FRIEND_INVITES,
context: {
location
},
rejectWithError: rejectWithMigratedError()
}).then((result) => {
Dispatcher.dispatch({
type: "FRIEND_INVITE_REVOKE_SUCCESS",
invites: result.body
});
});
},
revokeFriendInvite: (a0) => HTTP.del({
url: Endpoints.INVITE(a0),
rejectWithError: rejectWithMigratedError()
}),
fetchFriendMembers: async (a0) => {
let env15855 = {
$parent: env4292
};
env15855[0] = a0;
let c25966_0, c25966_1, c25966_2;
let c25966_3 = 0;
const r12 = env15855;
L10: {
try {
let env29827;
c25966_1 = r12;
const r28 = env29827 = {
$parent: r12
};
c25966_0 = r28;
env29827[0] = void 0;
c25966_3 = 1;
env29827[0] = (await TrackedHTTPUtils.get({
url: Endpoints.INVITE_FRIEND_MEMBERS(env15855[0]),
trackedActionData: {
event: NetworkActionNames.INVITE_FRIEND_MEMBERS_FETCH,
properties: (a0) => {
const r3 = a0 == null;
let friend_count = void 0;
if (!r3) {
const body = a0.body;
friend_count = body == null ? void 0 : body.friend_member_ids?.length;
}
if (friend_count == null) {
friend_count = 0;
}
return exact({
code: env15855[0],
friend_count
});
}
},
rejectWithError: true
})).body;
Dispatcher.dispatch({
type: "INVITE_FRIEND_MEMBERS_FETCH_SUCCESS",
code: env15855[0],
friendMemberIds: env29827[0].friend_member_ids
});
c25966_3 = 0;
} catch ($e) {
const r26 = $e;
let r8 = r26;
c25966_2 = r26;
if (c25966_3 !== 0) {
while (true) {
try {
c25966_3 = 0;
Dispatcher.dispatch({
type: "INVITE_FRIEND_MEMBERS_FETCH_FAILURE",
code: env15855[0]
});
break L10;
} catch (r77) {
r8 = r77;
c25966_2 = r77;
if (c25966_3 === 0) {
break;
}
}
}
}
throw r8;
}
}
},
clearInviteFromStore: (a0) => {
Dispatcher.dispatch({
type: "INSTANT_INVITE_CLEAR",
channelId: a0
});
},
revokeInvite: (a0) => {
const { code, channel } = a0;
return TrackedHTTPUtils.delete({
url: Endpoints.INVITE(code),
oldFormErrors: true,
trackedActionData: {
event: NetworkActionNames.INVITE_REVOKE,
properties: {
uses: a0.uses,
max_uses: a0.maxUses,
max_age: a0.maxAge,
invite_type: a0.type
}
},
rejectWithError: rejectWithMigratedError()
}).then(() => {
Dispatcher.dispatch({
type: "INSTANT_INVITE_REVOKE_SUCCESS",
code,
channelId: channel.id
});
});
},
acceptInvite: function acceptInvite(a0) {
let r78, invite_guild_scheduled_event_id;
let env15857 = {
$parent: env4292
};
const inviteKey = a0.inviteKey;
env15857[0] = inviteKey;
const context = a0.context;
env15857[1] = a0.callback;
env15857[2] = a0.skipOnboarding;
env15857[3] = void 0;
env15857[4] = void 0;
env15857[5] = void 0;
env15857[6] = void 0;
env15857[8] = void 0;
env15857[9] = void 0;
env15857[7] = this;
const r17 = parseInviteCodeFromInviteKey(inviteKey);
env15857[8] = r17;
const sessionId = AuthenticationStore.getSessionId();
const receivedInstallationIdForInviteCode = InstantInviteStore.getReceivedInstallationIdForInviteCode(r17);
env15857[9] = receivedInstallationIdForInviteCode;
const invite = InviteStore.getInvite(inviteKey);
if (invite != null) {
const guild_scheduled_event = invite.guild_scheduled_event;
env15857[3] = guild_scheduled_event;
const id = guild_scheduled_event?.id;
env15857[6] = id;
let target_channel_id2 = invite.target_channel_id;
if (target_channel_id2 == null) {
target_channel_id2 = void 0;
}
env15857[4] = target_channel_id2;
let target_message_id2 = invite.target_message_id;
if (target_message_id2 == null) {
target_message_id2 = void 0;
}
env15857[5] = target_message_id2;
invite_guild_scheduled_event_id = id;
} else {
const r35 = parseExtraDataFromInviteKey(inviteKey);
invite_guild_scheduled_event_id = r35.guildScheduledEventId;
env15857[6] = invite_guild_scheduled_event_id;
env15857[4] = r35.targetChannelId;
env15857[5] = r35.targetMessageId;
}
const context2 = {
...context,
invite_guild_scheduled_event_id
};
const currentUser = UserStore.getCurrentUser();
if (currentUser == null ? void 0 : currentUser.hasFlag(UserFlags.QUARANTINED)) {
openQuarantineModeInfoModal_native();
r78 = new Promise((resolve, reject) => reject(new Error()));
} else {
Dispatcher.dispatch({
type: "INVITE_ACCEPT",
code: inviteKey
});
const r70 = HTTP.post({
url: Endpoints.INVITE(r17),
context: context2,
oldFormErrors: true,
body: {
session_id: sessionId,
invite_instance_id: context.invite_instance_id,
received_installation_id: receivedInstallationIdForInviteCode
},
rejectWithError: rejectWithMigratedError()
});
let c15858_0 = async (c29828_0) => {
let body, body2;
let guildScheduledEvent, target_channel_id, target_message_id, guild_id, flags, c29828_7;
let c31433_0, c31433_1, c31433_2, c31433_3;
L36: {
L33: {
c29828_7 = void 0;
c31433_0 = c29828_0;
c31433_1 = void 0;
c31433_2 = void 0;
c31433_3 = void 0;
if (env15857[9] != null) {
env15857[7].clearReceivedInstallationIdForInviteCode(env15857[8]);
}
Dispatcher.dispatch({
type: "INVITE_ACCEPT_SUCCESS",
invite: c29828_0.body,
code: env15857[0]
});
guildScheduledEvent = env15857[3];
if (guildScheduledEvent == null) {
guildScheduledEvent = GuildScheduledEventStore.getGuildScheduledEvent(env15857[6]);
}
const target_channel_id2 = c29828_0.body.target_channel_id;
target_channel_id = target_channel_id2;
if (target_channel_id2 == null) {
target_channel_id = env15857[4];
}
const target_message_id2 = c29828_0.body.target_message_id;
target_message_id = target_message_id2;
if (target_message_id2 == null) {
target_message_id = env15857[5];
}
const r44 = {
...c29828_0.body,
guild_scheduled_event: guildScheduledEvent,
target_channel_id,
target_message_id
};
c31433_1 = r44;
const guild_id2 = r44.guild_id;
guild_id = guild_id2;
if (guild_id2 == null) {
guild_id = r44.guild?.id;
}
c31433_2 = guild_id;
flags = r44.flags;
if (flags == null) {
flags = 0;
}
const hasFlag = _Module1384.hasFlag(flags, GuildInviteFlags.IS_GUEST_INVITE);
if (!env15857[2] && !hasFlag && guild_id != null && r44.new_member && !r44.show_verification_form) {
c31433_3 = (await import("../modules/guild_onboarding/doGuildOnboarding.native")).default;
await (0, c31433_3)({
guildId: c31433_2
});
const r121 = env15857[1];
if (r121 != null) {
r121(c31433_1);
}
body = c31433_0.body;
break L33;
}
const r77 = env15857[1];
if (r77 != null) {
r77(c31433_1);
}
body2 = c31433_0.body;
break L36;
}
return body;
}
return body2;
};
r78 = r70.then(function() {
return c15858_0.apply(this, arguments);
}, (a0) => {
if (a0.body?.code === AbortCodes.USER_GUILD_JOIN_LARGE_GUILD_UNDERAGE_DISALLOWED) {
openAgeGateModal(AgeGateSource.JOIN_LARGE_GUILD_UNDERAGE);
}
Dispatcher.dispatch({
type: "INVITE_ACCEPT_FAILURE",
code: env15857[0],
error: {
message: a0.body?.message,
code: a0.body?.code
}
});
throw new V6OrEarlierAPIError(a0);
});
}
return r78;
},
acceptInviteAndTransitionToInviteChannel: function acceptInviteAndTransitionToInviteChannel({ inviteKey, context, analyticsLocations, callback: callback2, skipOnboarding, autoJoin }) {
return this.acceptInvite({
inviteKey,
context,
skipOnboarding,
callback: (a0) => {
if (a0.channel != null) {
const r8 = {};
const r6 = env4292;
HermesBuiltin.copyDataProperties(r8, generateAcceptInviteOptions(a0));
r8.autoJoin = autoJoin;
const id = a0.channel.id;
let r7 = analyticsLocations;
if (analyticsLocations == null) {
r7 = [];
}
let env25967;
const r16 = env25967 = {
$parent: r6
};
env25967[0] = id;
env25967[1] = r8;
if (r7 === void 0) {
r7 = [];
}
env25967[2] = r7;
ChannelStore.addConditionalChangeListener($mk78931(r16));
}
if (callback2 != null) {
callback2(a0);
}
}
});
},
transitionToInvite: function transitionToInvite(a0, r13 = {}) {
L33: {
const { transitionTo, muteOnJoinVoiceChannel, intent, forceTransition } = r13;
const { channel: channel2, guild, inviter } = a0;
if (channel2 == null && (guild == null && inviter != null)) {
const r20 = RelationshipStore.isFriend(inviter.id) ? ChannelStore.getDMFromUserId(inviter.id) : null;
if (r20 == null) {
break L33;
}
let env15860;
const r24 = env15860 = {
$parent: env4292
};
env15860[0] = r20;
env15860[1] = r13;
env15860[2] = [];
ChannelStore.addConditionalChangeListener($mk78931(r24));
} else {
if (guild != null) {
const features = guild.features;
if (features == null ? void 0 : features.includes(GuildFeatures.HUB)) {
HubUtils_native.onOpenHubInvite(a0);
break L33;
}
}
let flags2 = a0.flags;
if (flags2 == null) {
flags2 = 0;
}
let r44 = _Module1384.hasFlag(flags2, GuildInviteFlags.IS_GUEST_INVITE);
const r18 = flags2;
if (!r44) {
r44 = _Module1384.hasFlag(r18, GuildInviteFlags.IS_APPLICATION_BYPASS);
}
if (guild != null && (!r44 && (a0.new_member && inviteGuildHasPendingMemberDisabledVerification(guild)))) {
openVerificationModalOrTransitionToApplication(guild.id);
} else if (channel2 != null) {
const r63 = generateAcceptInviteOptions(a0);
if (transitionTo != null) {
r63.transitionTo = transitionTo;
}
if (intent != null) {
r63.intent = intent;
}
if (muteOnJoinVoiceChannel != null) {
r63.muteOnJoinVoiceChannel = muteOnJoinVoiceChannel;
}
if (forceTransition != null) {
r63.forceTransition = forceTransition;
}
let env15861;
const id = channel2.id;
const r65 = env15861 = {
$parent: env4292
};
env15861[0] = id;
env15861[1] = r63;
env15861[2] = [];
ChannelStore.addConditionalChangeListener($mk78931(r65));
}
}
}
},
openNativeAppModal: (a0) => {
const r9 = parseExtraDataFromInviteKey(a0);
CodedLinkActionCreators.openNativeAppModal(r9.baseCode, RPCCommands.INVITE_BROWSER, {
installationId: AuthenticationStore.getInstallationForTracking(),
targetChannelId: r9.targetChannelId,
targetMessageId: r9.targetMessageId,
guildScheduledEventId: r9.guildScheduledEventId
});
},
transitionToInviteOnboarding: function transitionToInviteOnboarding(a0, r2 = {}) {
let transitionTo = r2.transitionTo;
if (transitionTo === void 0) {
transitionTo = _router_utils.transitionTo;
}
let target_channel_id2 = a0.target_channel_id;
if (target_channel_id2 == null) {
target_channel_id2 = void 0;
}
let target_message_id2 = a0.target_message_id;
if (target_message_id2 == null) {
target_message_id2 = void 0;
}
const r22 = generateInviteKeyFromExtraData({
baseCode: a0.code,
targetChannelId: target_channel_id2,
targetMessageId: target_message_id2,
guildScheduledEventId: a0.guild_scheduled_event?.id
});
transitionTo(Routes.APP_WITH_INVITE_AND_GUILD_ONBOARDING(a0.code), {
search: getInviteKeySearchSuffix(r22)
});
},
openApp: (a0, a1, a2, a3, a4) => {
let r17, r74, r79;
const code2 = a0;
const r20 = a0 != null ? parseExtraDataFromInviteKey(a0) : null;
const baseCode = r20?.baseCode;
const targetMessageId = r20?.targetMessageId;
const targetChannelId = r20?.targetChannelId;
Dispatcher.dispatch({
type: "INVITE_APP_OPENING",
code: a0
});
if (Module4508.ua != null && Module4508.ua.toLowerCase().indexOf("googlebot") > -1) {
Dispatcher.dispatch({
type: "INVITE_APP_NOT_OPENED",
code: a0
});
} else {
const family = Module4508.os?.family;
L32: {
if (family !== "Android") {
if (Module4508.os?.family !== "iOS" && !isTablet) {
const r11 = a1 == null ? targetChannelId : a1;
const r62 = r11 != null ? Routes.INVITE_PROXY(r11, targetMessageId) : "";
r74 = `discord://${r62[0] === "#" ? r62.slice(1) : r62}`;
break L32;
}
}
if (baseCode != null) {
r79 = getInviteDynamicLinkTemplate(baseCode);
r17 = require;
} else {
r79 = getDefaultDynamicLinkTemplate();
r17 = require;
}
const attemptId = r17(dependencyMap[61]).generateAttemptId();
let utmSource = "friend_invite";
const r18 = r17;
if (a4 !== 2) {
utmSource = c4292_39;
}
r74 = generateDynamicLink(r79, {
utmSource,
fingerprint: a2,
installationId: AuthenticationStore.getInstallationForTracking(),
username: a3,
attemptId,
event: r20?.guildScheduledEventId,
channel: targetChannelId,
message: targetMessageId,
iosFallbackLink: `https://discord.com/api/download/mobile?invite_code=${baseCode}`
});
AnalyticsUtils.track(AnalyticEvents.DEEP_LINK_CLICKED, {
fingerprint: r18(dependencyMap[62]).maybeExtractId(a2),
attempt_id: attemptId,
source: c4292_39,
invite_code: baseCode
});
}
ProtocolUtils.launch(r74, (a0) => {
Dispatcher.dispatch(a0 ? {
type: "INVITE_APP_OPENED",
code: code2
} : {
type: "INVITE_APP_NOT_OPENED",
code: code2
});
});
}
},
setReceivedInstallationIdForInviteCode: (a0, a1) => {
Dispatcher.dispatch({
type: "INSTANT_INVITE_RECEIVED_INSTALLATION_ID_SET",
inviteCode: a0,
receivedInstallationId: a1
});
},
clearReceivedInstallationIdForInviteCode: (a0) => {
Dispatcher.dispatch({
type: "INSTANT_INVITE_RECEIVED_INSTALLATION_ID_CLEAR",
inviteCode: a0
});
},
trackInviteServerClicked
};
export default r86;
export async function transitionToGuildFromEventInvite(c25961_0) {
L13: {
L11: {
const { guild_id: guild_id2, channel_id } = c25961_0;
if ((0, isGuildScheduledEventActive)(c25961_0) && channel_id != null) {
transitionToInviteChannelSync(channel_id);
break L11;
}
await GuildActionCreators.transitionToGuildSync(guild_id2);
break L13;
}
return void 0;
}
}
export function trackInviteEmbedActioned(a0, a1) {
const { invite, action } = a0;
let inviter_id = a0.inviter_id;
let invite_message_id = a0.invite_message_id;
let invite_instance_id = a0.invite_instance_id;
let application_id = a0.application_id;
let stream_key = a0.stream_key;
let number_of_users_in_channel = a0.number_of_users_in_channel;
const INVITE_EMBED_ACTIONED = AnalyticEvents.INVITE_EMBED_ACTIONED;
const type = invite.type;
const invite_type = type == null ? void 0 : type.toString();
if (inviter_id == null) {
inviter_id = null;
}
if (invite_message_id == null) {
invite_message_id = null;
}
if (invite_instance_id == null) {
invite_instance_id = null;
}
if (application_id == null) {
application_id = null;
}
if (stream_key == null) {
stream_key = null;
}
if (number_of_users_in_channel == null) {
number_of_users_in_channel = null;
}
AnalyticsUtils.track(INVITE_EMBED_ACTIONED, {
action,
invite_code: invite.code,
invite_type,
inviter_id,
invite_message_id,
invite_instance_id,
application_id,
stream_key,
number_of_users_in_channel,
location_stack: a1 == null ? null : a1
});
}