// Metro module 5183 (f5184). import ImpersonateStore from "../impersonate/ImpersonateStore"; import GuildMemberStore from "../../stores/GuildMemberStore"; import InviteStore from "../../stores/InviteStore"; import UserStore from "../../stores/UserStore"; import { Endpoints, AnalyticEvents } from "../../Constants"; import { HTTP, rejectWithMigratedError } from "../../_bundle/sendRequest"; import { parseInviteCodeFromInviteKey } from "../instant_invite/InviteCodeUtils"; import Dispatcher from "../../Dispatcher"; import { buildGuildProfileFromServer } from "../guild_profile/GuildProfileBuilders"; import { updateImpersonatedData } from "../impersonate/ImpersonateActionCreators"; import { hasNonTermsFormField } from "./MemberVerificationTypes"; import { closeContextMenu } from "../../actions/ContextMenuActionCreators"; import AlertActionCreators from "../../actions/AlertActionCreators"; import { intl, t } from "../../intl/index.native"; import { APIError } from "../../errors/index"; import AnalyticsUtils from "../../utils/AnalyticsUtils"; function $mk114664($env) { return () => { Dispatcher.dispatch({ type: "USER_GUILD_JOIN_REQUEST_COACHMARK_SHOW", guildId: $env[0] }); }; } let env3130 = {}; const r33 = { fetchVerificationForm: async function fetchVerificationForm(c25367_0, c25367_1) { let r112; let inviteKeyForGuildId; let c25367_6 = 0; let c29468_0, c29468_1, c29468_2; try { c29468_0 = c25367_0; c29468_1 = void 0; c29468_2 = void 0; inviteKeyForGuildId = c25367_1; if (c25367_1 == null) { inviteKeyForGuildId = InviteStore.getInviteKeyForGuildId(c25367_0); } const r21 = inviteKeyForGuildId; const with_guild = !GuildMemberStore.isMember(c25367_0, UserStore.getCurrentUser()?.id); c25367_6 = 1; c29468_1 = await HTTP.get({ url: Endpoints.GUILD_MEMBER_VERIFICATION(c25367_0), query: { with_guild, invite_code: r21 != null ? parseInviteCodeFromInviteKey(r21) : void 0 }, oldFormErrors: true, rejectWithError: rejectWithMigratedError() }); if (c29468_1.body == null) { throw c29468_1; } c29468_2 = c29468_1.body; Dispatcher.dispatch({ type: "MEMBER_VERIFICATION_FORM_UPDATE", guildId: c29468_0, form: { version: c29468_2.version, description: c29468_2.description, formFields: c29468_2.form_fields, guild: c29468_2.guild, profile: c29468_2.profile != null ? buildGuildProfileFromServer(c29468_2.profile) : null } }); r112 = c29468_2; c25367_6 = 0; } catch ($e) { let r8 = $e; if (c25367_6 !== 0) { while (true) { try { c25367_6 = 0; Dispatcher.dispatch({ type: "MEMBER_VERIFICATION_FORM_FETCH_FAIL", guildId: c29468_0 }); } catch ($e) { r8 = $e; if (c25367_6 === 0) { break; } continue; } return void 0; } } throw r8; } return r112; }, updateVerificationForm: async function updateVerificationForm(c25368_0, form_fields, enabled, bulk_action) { let c29469_0 = c25368_0; let c29469_1 = (await HTTP.patch({ url: Endpoints.GUILD_MEMBER_VERIFICATION(c25368_0), body: { form_fields, enabled, bulk_action }, oldFormErrors: true, rejectWithError: rejectWithMigratedError() })).body; Dispatcher.dispatch({ type: "MEMBER_VERIFICATION_FORM_UPDATE", guildId: c29469_0, form: { version: c29469_1.version, description: c29469_1.description, formFields: c29469_1.form_fields } }); }, updateVerificationFormFieldsLocal: function updateVerificationFormFieldsLocal(a0, a1) { Dispatcher.dispatch({ type: "MEMBER_VERIFICATION_FORM_UPDATE", guildId: a0, form: { formFields: a1 }, isLocalUpdate: true }); }, updateVerificationFormDescription: async function updateVerificationFormDescription(c25369_0, description) { let c29470_0 = c25369_0; let c29470_1 = (await HTTP.patch({ url: Endpoints.GUILD_MEMBER_VERIFICATION(c25369_0), body: { description }, oldFormErrors: true, rejectWithError: rejectWithMigratedError() })).body; Dispatcher.dispatch({ type: "MEMBER_VERIFICATION_FORM_UPDATE", guildId: c29470_0, form: { version: c29470_1.version, description: c29470_1.description, formFields: c29470_1.form_fields } }); }, updateVerificationFormDescriptionLocal: function updateVerificationFormDescriptionLocal(a0, a1) { Dispatcher.dispatch({ type: "MEMBER_VERIFICATION_FORM_UPDATE", guildId: a0, form: { description: a1 }, isLocalUpdate: true }); }, enableVerificationForm: async function enableVerificationForm(c25370_0, enabled2) { await HTTP.patch({ url: Endpoints.GUILD_MEMBER_VERIFICATION(c25370_0), body: { enabled: enabled2 }, oldFormErrors: true, rejectWithError: rejectWithMigratedError() }); }, submitVerificationForm: async function submitVerificationForm(c25371_0, c25371_1, c25371_2) { let r145; let anyErrorMessage, c25371_4, c25371_5, c25371_6; let c25371_7 = 0; const r15 = env3130; L21: { try { let env29471; c25371_5 = r15; const r40 = env29471 = { $parent: r15 }; c25371_4 = r40; env29471[2] = void 0; env29471[0] = c25371_0; env29471[1] = c25371_1; if (c25371_2 !== void 0) { env29471[2] = c25371_2; env29471[3] = void 0; } else { env29471[2] = 200; env29471[3] = void 0; } await void 0; if (ImpersonateStore.isFullServerPreview(env29471[0])) { updateImpersonatedData(env29471[0], { memberOptions: { isPending: false } }); break L21; } c25371_7 = 1; env29471[3] = (await HTTP.put({ url: Endpoints.GUILD_MEMBER_REQUEST_TO_JOIN(env29471[0]), body: { version: env29471[1].version, form_fields: env29471[1].formFields }, rejectWithError: rejectWithMigratedError() })).body; Dispatcher.dispatch({ type: "USER_GUILD_JOIN_REQUEST_UPDATE", guildId: env29471[0], request: env29471[3] }); if (hasNonTermsFormField(env29471[1].formFields) && env29471[2] !== -1) { const r147 = c25371_4; const r148 = setTimeout; const r149 = env29471[2]; r148($mk114664(r147), r149); } r145 = env29471[3]; c25371_7 = 0; } catch ($e) { const r38 = $e; let r8 = r38; c25371_6 = r38; if (c25371_7 !== 0) { while (true) { try { const r158 = c25371_6; c25371_7 = 0; env29471[4] = r158; const status = env29471[4].status; if (status === 429) { closeContextMenu(); AlertActionCreators.show({ title: intl.string(t.MmIrpf), body: intl.string(t.yjpDQ3), confirmText: intl.string(t.XNGT1O) }); throw { ...env29471[4], message: intl.string(t.yjpDQ3) }; } if (status === 403) { throw { ...env29471[4], message: intl.string(t["8T1rxN"]) }; } anyErrorMessage = new APIError(env29471[4]).getAnyErrorMessage(); if (anyErrorMessage == null) { anyErrorMessage = intl.string(t.R0RpRX); } throw { ...env29471[4], message: anyErrorMessage }; } catch (r155) { r8 = r155; c25371_6 = r155; if (c25371_7 === 0) { break; } } } } throw r8; } return r145; } }, clearCoachmark: function clearCoachmark() { Dispatcher.dispatch({ type: "USER_GUILD_JOIN_REQUEST_COACHMARK_CLEAR" }); }, reportApplication: function reportApplication(a0) { const { guild, guildJoinRequest } = a0; AnalyticsUtils.track(AnalyticEvents.GUILD_MEMBER_APPLICATION_REPORTED, { application_id: guildJoinRequest.joinRequestId, applicant_id: a0.guildJoinRequestUser.id, guild_id: guild.id, reason: a0.reason, reason_other: a0.reasonOther, responses: a0.responses }); } }; export default r33; export const DISABLE_JOIN_REQUEST_COACHMARK = -1; export function showCoachmark(a0) { Dispatcher.dispatch({ type: "USER_GUILD_JOIN_REQUEST_COACHMARK_SHOW", guildId: a0 }); }