// Metro module 9156 (f9157). import { createChannelRecordFromServer } from "../../records/ChannelRecord"; import GuildJoinRequestStore from "./GuildJoinRequestStore"; import { joinRequestFromServer } from "./UserGuildJoinRequestStore"; import { AbortCodes, Endpoints } from "../../Constants"; import { GuildJoinRequestApplicationStatuses, MAX_RESULTS_PER_PAGE } from "./MemberVerificationTypes"; import Dispatcher from "../../Dispatcher"; import { HTTP, rejectWithMigratedError } from "../../_bundle/sendRequest"; import { trackMemberApplicationAction, trackMemberApplicationViewed } from "./GuildJoinRequestAnalyticUtils"; import AlertActionCreators from "../../actions/AlertActionCreators"; import { intl, t } from "../../intl/index.native"; import SelectedChannelActionCreators from "../../actions/SelectedChannelActionCreators"; function $mk115421($env) { return (a0) => { let r1 = a0 ? a0.body : a0; if (r1) { r1 = a0.body.code === AbortCodes.REQUEST_TO_JOIN_USER_INELIGIBLE; } if (r1) { AlertActionCreators.show({ title: intl.string(t.DxJj4e), body: intl.string(t.rSAOk9) }); } return Promise.reject(a0); }; } let env6008 = {}; const r36 = { fetchGuildJoinRequests: async function fetchGuildJoinRequests(c26371_0) { let r150; let guild_join_requests, c26371_4; let c26371_5 = 0; let c30042_0, c30042_1, c30042_2, c30042_3, c30042_4, c30042_5, c30042_6, c30042_7, c30042_8, c30042_9, c30042_10; L26: { try { c30042_0 = void 0; c30042_1 = void 0; c30042_2 = void 0; c30042_3 = void 0; c30042_4 = void 0; c30042_5 = void 0; c30042_0 = c26371_0.guildId; let status = c26371_0.status; if (status === void 0) { status = GuildJoinRequestApplicationStatuses.SUBMITTED; } c30042_1 = status; c30042_2 = c26371_0.before; c30042_3 = c26371_0.after; let limit = c26371_0.limit; if (limit === void 0) { limit = MAX_RESULTS_PER_PAGE; } c30042_4 = limit; const force = c26371_0.force; if (force !== void 0) { c30042_5 = force; c30042_6 = void 0; c30042_7 = void 0; c30042_8 = void 0; c30042_9 = void 0; } else { c30042_5 = false; c30042_6 = void 0; c30042_7 = void 0; c30042_8 = void 0; c30042_9 = void 0; } await void 0; c30042_6 = c30042_5 || !GuildJoinRequestStore.hasFetched(c30042_0); if (GuildJoinRequestStore.isFetching()) { break L26; } if (!c30042_6) { break L26; } Dispatcher.dispatch({ type: "GUILD_JOIN_REQUESTS_FETCH_START" }); c26371_5 = 1; c30042_7 = await HTTP.get({ url: Endpoints.GUILD_JOIN_REQUESTS(c30042_0), query: { status: c30042_1, limit: c30042_4, before: c30042_2, after: c30042_3 }, rejectWithError: rejectWithMigratedError() }); c30042_8 = c30042_7.body.total; const guild_join_requests2 = c30042_7.body.guild_join_requests; guild_join_requests = guild_join_requests2; if (guild_join_requests2 == null) { guild_join_requests = []; } c30042_9 = guild_join_requests.map(joinRequestFromServer); Dispatcher.dispatch({ type: "GUILD_JOIN_REQUESTS_FETCH_SUCCESS", status: c30042_1, requests: c30042_9, total: c30042_8, limit: c30042_4, guildId: c30042_0 }); r150 = c30042_7; c26371_5 = 0; } catch ($e) { const r31 = $e; let r8 = r31; c26371_4 = r31; if (c26371_5 !== 0) { while (true) { try { const r160 = c26371_4; c26371_5 = 0; c30042_10 = r160; Dispatcher.dispatch({ type: "GUILD_JOIN_REQUESTS_FETCH_FAILURE" }); throw c30042_10; } catch (r156) { r8 = r156; c26371_4 = r156; if (c26371_5 === 0) { break; } } } } throw r8; } return r150; } }, fetchGuildJoinRequestsForUser: async function fetchGuildJoinRequestsForUser(c26372_0, c26372_1) { let c30043_0 = c26372_0; let c30043_1 = c26372_1; let c30043_2 = await HTTP.get({ url: Endpoints.GUILD_JOIN_REQUESTS_FOR_USER(c26372_0, c26372_1), rejectWithError: rejectWithMigratedError() }); const body2 = c30043_2.body; let body = body2; if (body2 == null) { body = []; } let c30043_3 = body.map(joinRequestFromServer); Dispatcher.dispatch({ type: "GUILD_JOIN_REQUESTS_FOR_USER_FETCH_SUCCESS", guildId: c30043_0, userId: c30043_1, requests: c30043_3 }); return c30043_2; }, ackUserGuildJoinRequest: async function ackUserGuildJoinRequest(c26374_0, c26374_1) { let r24; let c26374_4; let c26374_5 = 0; let c30045_0, c30045_1; try { c30045_0 = c26374_0; c30045_1 = c26374_1; c26374_5 = 2; r24 = await HTTP.post({ url: Endpoints.GUILD_JOIN_REQUEST_ACK(c26374_0, c26374_1), rejectWithError: rejectWithMigratedError() }); c26374_5 = 0; Dispatcher.dispatch({ type: "ACK_APPROVED_GUILD_JOIN_REQUEST", id: c30045_1, guildId: c30045_0 }); } catch ($e) { const r28 = $e; let r8 = r28; c26374_4 = r28; let r29 = c26374_5; if (r29 !== 0) { while (true) { if (r29 !== 1) { try { c26374_5 = 0; Dispatcher.dispatch({ type: "ACK_APPROVED_GUILD_JOIN_REQUEST", id: c30045_1, guildId: c30045_0 }); } catch (r72) { r8 = r72; c26374_4 = r72; r29 = c26374_5; if (r29 === 0) { break; } continue; } return void 0; } try { const r91 = c26374_4; c26374_5 = 0; Dispatcher.dispatch({ type: "ACK_APPROVED_GUILD_JOIN_REQUEST", id: c30045_1, guildId: c30045_0 }); throw r91; } catch (r88) { r8 = r88; c26374_4 = r88; r29 = c26374_5; if (r29 === 0) { break; } } } } throw r8; } return r24; }, removeGuildJoinRequest: async function removeGuildJoinRequest(c26373_0) { let r65; let c26373_3; let c26373_4 = 0; let c30044_0, c30044_1; try { c30044_0 = c26373_0; c30044_1 = void 0; c26373_4 = 1; c30044_1 = await HTTP.del({ url: Endpoints.GUILD_MEMBER_REQUEST_TO_JOIN(c26373_0), rejectWithError: rejectWithMigratedError() }); Dispatcher.dispatch({ type: "USER_GUILD_JOIN_REQUEST_UPDATE", guildId: c30044_0, request: null }); r65 = c30044_1; c26373_4 = 0; } catch ($e) { const r26 = $e; let r8 = r26; c26373_3 = r26; if (c26373_4 !== 0) { while (true) { try { const r72 = c26373_3; c26373_4 = 0; throw r72; } catch (r70) { r8 = r70; c26373_3 = r70; if (c26373_4 === 0) { break; } } } } throw r8; } return r65; }, updateGuildJoinRequest: async function updateGuildJoinRequest(c26375_0, c26375_1, c26375_2, c26375_3, c26375_4) { let env30046; const r12 = env6008; let c26375_6 = r12; const r10 = env30046 = { $parent: r12 }; let c26375_5 = r10; env30046[3] = void 0; env30046[4] = void 0; env30046[0] = c26375_0; env30046[1] = c26375_1; env30046[2] = c26375_2; let r34 = c26375_3; if (r34 === void 0) { r34 = GuildJoinRequestApplicationStatuses.APPROVED; } env30046[3] = r34; env30046[4] = c26375_4; env30046[5] = void 0; await void 0; trackMemberApplicationAction({ guildId: env30046[0], actionType: env30046[3], applicationUserId: env30046[1] }); env30046[5] = await HTTP.patch({ url: Endpoints.GUILD_JOIN_REQUEST(env30046[0], env30046[2]), body: { action: env30046[3], rejection_reason: env30046[4] }, rejectWithError: rejectWithMigratedError() }).catch($mk115421(env6008)); Dispatcher.dispatch({ type: "GUILD_JOIN_REQUEST_UPDATE", guildId: env30046[0], status: env30046[5].body.application_status, request: env30046[5].body }); }, resetGuildJoinRequest: async function resetGuildJoinRequest(c26376_0) { let r67; let c26376_3; let c26376_4 = 0; let c30047_0, c30047_1; try { c30047_0 = c26376_0; c30047_1 = void 0; c26376_4 = 1; c30047_1 = (await HTTP.post({ url: Endpoints.GUILD_MEMBER_REQUEST_TO_JOIN(c26376_0), rejectWithError: rejectWithMigratedError() })).body; Dispatcher.dispatch({ type: "USER_GUILD_JOIN_REQUEST_UPDATE", guildId: c30047_0, request: c30047_1 }); r67 = c30047_1; c26376_4 = 0; } catch ($e) { const r26 = $e; let r8 = r26; c26376_3 = r26; if (c26376_4 !== 0) { while (true) { try { const r74 = c26376_3; c26376_4 = 0; throw r74; } catch (r72) { r8 = r72; c26376_3 = r72; if (c26376_4 === 0) { break; } } } } throw r8; } return r67; }, fetchRequestToJoinGuilds: async function fetchRequestToJoinGuilds() { let c30048_0 = await HTTP.get({ url: Endpoints.USER_JOIN_REQUEST_GUILDS, rejectWithError: rejectWithMigratedError() }); Dispatcher.dispatch({ type: "USER_JOIN_REQUEST_GUILDS_FETCH", guilds: c30048_0.body }); }, setSelectedApplicationTab: function setSelectedApplicationTab(a0, a1) { Dispatcher.dispatch({ type: "GUILD_JOIN_REQUESTS_SET_APPLICATION_TAB", guildId: a0, applicationTab: a1 }); }, setSelectedSortOrder: function setSelectedSortOrder(a0, a1, a2) { Dispatcher.dispatch({ type: "GUILD_JOIN_REQUESTS_SET_SORT_ORDER", guildId: a0, sortOrder: a1, applicationStatus: a2 }); }, setSelectedGuildJoinRequest: function setSelectedGuildJoinRequest(a0, a1) { if (a1 != null) { trackMemberApplicationViewed({ guildId: a0, applicationStatus: a1.applicationStatus, applicationUserId: a1.userId }); } Dispatcher.dispatch({ type: "GUILD_JOIN_REQUESTS_SET_SELECTED", guildId: a0, request: a1 }); }, fetchJoinRequestForInterview: async function fetchJoinRequestForInterview(c26378_0) { let c30049_0 = await HTTP.get({ url: Endpoints.JOIN_REQUEST(c26378_0), rejectWithError: rejectWithMigratedError() }); let c30049_1 = (0, joinRequestFromServer)(c30049_0.body); Dispatcher.dispatch({ type: "GUILD_JOIN_REQUEST_BY_ID_FETCH_SUCCESS", joinRequest: c30049_1 }); return c30049_0; }, createOrEnterJoinRequestInterview: async function createOrEnterJoinRequestInterview(c26379_0, c26379_1) { let c30050_1, c30050_2, c30050_3; c30050_1 = void 0; let c30050_0 = c26379_0; if (c26379_1 !== void 0) { c30050_1 = c26379_1; c30050_2 = void 0; c30050_3 = void 0; } else { c30050_1 = true; c30050_2 = void 0; c30050_3 = void 0; } await void 0; c30050_2 = await HTTP.post({ url: Endpoints.JOIN_REQUEST_INTERVIEW(c30050_0), rejectWithError: rejectWithMigratedError() }); c30050_3 = (0, createChannelRecordFromServer)(c30050_2.body); Dispatcher.dispatch({ type: "CHANNEL_CREATE", channel: c30050_3 }); if (c30050_1) { SelectedChannelActionCreators.selectPrivateChannel(c30050_3.id); } return c30050_3.id; } }; export default r36;