// Metro module 8208 (f8209). import AuthenticationStore from "../../stores/AuthenticationStore"; import GuildScheduledEventStore from "./GuildScheduledEventStore"; import { ENTITY_TYPES_REQUIRED_CHANNEL_ID, ENTITY_TYPES_REQUIRED_ENTITY_METADATA, GuildScheduledEventStatus, MAX_RSVP_USER_DISPLAY_COUNT } from "./GuildScheduledEventsConstants"; import { Endpoints, Routes } from "../../Constants"; import { HTTP, rejectWithMigratedError } from "../../_bundle/sendRequest"; import SelectedChannelActionCreators from "../../actions/SelectedChannelActionCreators"; import { transitionTo } from "../routing/router_utils"; import { recurrenceRuleToServer } from "./utils/EditGuildEventUtils"; import { httpGetWithCountryCodeQuery } from "../../utils/StoreUtils"; import Dispatcher from "../../Dispatcher"; import { getExistingRsvp } from "./utils/GuildEventRsvpUtils"; import SnowflakeUtils from "../../utils/SnowflakeUtils"; const r29 = { startEvent: (a0, a1) => HTTP.patch({ url: Endpoints.GUILD_EVENT(a1, a0), body: { status: GuildScheduledEventStatus.ACTIVE }, rejectWithError: rejectWithMigratedError() }), endEvent: (a0, a1) => HTTP.patch({ url: Endpoints.GUILD_EVENT(a1, a0), body: { status: GuildScheduledEventStatus.COMPLETED }, rejectWithError: rejectWithMigratedError() }), joinVoiceEvent: (a0, a1) => { SelectedChannelActionCreators.selectVoiceChannel(a1); transitionTo(Routes.CHANNEL(a0, a1)); }, saveEvent: (a0, a1, a2) => { const channel_id = ENTITY_TYPES_REQUIRED_CHANNEL_ID.has(a1.entityType) ? a1.channelId : null; const entity_metadata = ENTITY_TYPES_REQUIRED_ENTITY_METADATA.has(a1.entityType) ? a1.entityMetadata : null; const body = { name: a1.name, description: a1.description, image: a1.image != null ? /^data:/.test(a1.image) !== false ? a1.image : void 0 : a1.image, privacy_level: a1.privacyLevel, scheduled_start_time: a1.scheduledStartTime, scheduled_end_time: a1.scheduledEndTime, entity_type: a1.entityType, channel_id, entity_metadata, recurrence_rule: recurrenceRuleToServer(a1.recurrenceRule) }; return HTTP.patch({ url: Endpoints.GUILD_EVENT(a2, a0), body, rejectWithError: rejectWithMigratedError() }); }, createGuildEvent: (a0, a1) => { const body = { name: a0.name, description: a0.description, image: a0.image, privacy_level: a0.privacyLevel, scheduled_start_time: a0.scheduledStartTime, scheduled_end_time: a0.scheduledEndTime, entity_type: a0.entityType, channel_id: a0.channelId, entity_metadata: a0.entityMetadata, recurrence_rule: recurrenceRuleToServer(a0.recurrenceRule) }; return HTTP.post({ url: Endpoints.GUILD_EVENTS_FOR_GUILD(a1), body, rejectWithError: rejectWithMigratedError() }); }, fetchGuildEvent: async (c16349_0, c16349_1) => { let c26141_1; c26141_1 = void 0; let c29905_0 = (await httpGetWithCountryCodeQuery({ url: Endpoints.GUILD_EVENT(c16349_0, c16349_1), rejectWithError: rejectWithMigratedError() })).body; Dispatcher.dispatch({ type: "FETCH_GUILD_EVENT", guildScheduledEvent: c29905_0 }); return c29905_0; }, fetchGuildEventsForGuild: async (c16350_0) => { let c26142_1; c26142_1 = void 0; let c29906_0 = (await httpGetWithCountryCodeQuery({ url: Endpoints.GUILD_EVENTS_FOR_GUILD(c16350_0), rejectWithError: rejectWithMigratedError() })).body; Dispatcher.dispatch({ type: "FETCH_GUILD_EVENTS_FOR_GUILD", guildId: c16350_0, guildScheduledEvents: c29906_0 }); return c29906_0; }, fetchGuildEventUserCounts: async (c16351_0, c16351_1, guild_scheduled_event_exception_ids) => { let c26143_1; c26143_1 = void 0; let c29907_0 = (await HTTP.get({ url: Endpoints.GUILD_EVENT_USER_COUNTS(c16351_0, c16351_1), query: { guild_scheduled_event_exception_ids }, rejectWithError: rejectWithMigratedError() })).body; let c29907_1 = { eventCount: c29907_0.guild_scheduled_event_count, recurrenceCounts: c29907_0.guild_scheduled_event_exception_counts }; Dispatcher.dispatch({ type: "GUILD_SCHEDULED_EVENT_USER_COUNTS_FETCH_SUCCESS", guildId: c16351_0, eventId: c16351_1, counts: c29907_1 }); return c29907_1; }, cancelGuildEvent: (a0, a1) => HTTP.patch({ url: Endpoints.GUILD_EVENT(a1, a0), body: { status: GuildScheduledEventStatus.CANCELED }, rejectWithError: rejectWithMigratedError() }), deleteGuildEvent: (a0, a1) => HTTP.del({ url: Endpoints.GUILD_EVENT(a1, a0), rejectWithError: rejectWithMigratedError() }), getGuildEventsForCurrentUser: async (c16352_0) => { let c26144_1; c26144_1 = void 0; let c29908_0 = (await HTTP.get({ url: Endpoints.USER_GUILD_EVENTS, query: { guild_ids: [c16352_0] }, rejectWithError: rejectWithMigratedError() })).body; Dispatcher.dispatch({ type: "GUILD_SCHEDULED_EVENT_RSVPS_FETCH_SUCESS", guildScheduledEventUsers: c29908_0, guildId: c16352_0 }); }, createRsvpForGuildEvent: async (guildEventId, guildEventExceptionId, guildId, response) => { let r66; let c26145_2; let c26145_3 = 0; let c29909_0, c29909_1; try { c29909_0 = void 0; const id = AuthenticationStore.getId(); c29909_0 = id; c26145_3 = 1; Dispatcher.dispatch({ type: "GUILD_SCHEDULED_EVENT_USER_ADD", userId: id, guildId, guildEventId, guildEventExceptionId, response }); r66 = await HTTP.put({ url: Endpoints.USER_GUILD_EVENT(guildId, guildEventId, guildEventExceptionId), body: { response }, rejectWithError: rejectWithMigratedError() }); c26145_3 = 0; } catch ($e) { const r31 = $e; let r8 = r31; c26145_2 = r31; if (c26145_3 !== 0) { while (true) { try { const r85 = c26145_2; c26145_3 = 0; c29909_1 = r85; Dispatcher.dispatch({ type: "GUILD_SCHEDULED_EVENT_USER_REMOVE", userId: c29909_0, guildId, guildEventId, guildEventExceptionId, response }); throw c29909_1; } catch (r81) { r8 = r81; c26145_2 = r81; if (c26145_3 === 0) { break; } } } } throw r8; } return r66; }, deleteRsvpForGuildEvent: async (guildEventId2, guildEventExceptionId2, guildId2) => { let r71; let c26146_2; let c26146_3 = 0; let c29910_0, c29910_1, c29910_2; L12: { try { c29910_0 = void 0; c29910_1 = void 0; const id = AuthenticationStore.getId(); c29910_0 = id; const rsvp = GuildScheduledEventStore.getRsvp(guildEventId2, guildEventExceptionId2, id); c29910_1 = rsvp; if (rsvp != null) { c26146_3 = 1; Dispatcher.dispatch({ type: "GUILD_SCHEDULED_EVENT_USER_REMOVE", userId: id, guildId: guildId2, guildEventId: guildEventId2, guildEventExceptionId: guildEventExceptionId2, response: rsvp.response }); r71 = await HTTP.del({ url: Endpoints.USER_GUILD_EVENT(guildId2, guildEventId2, guildEventExceptionId2), rejectWithError: rejectWithMigratedError() }); c26146_3 = 0; break L12; } } catch ($e) { const r32 = $e; let r8 = r32; c26146_2 = r32; if (c26146_3 !== 0) { while (true) { try { const r91 = c26146_2; c26146_3 = 0; c29910_2 = r91; Dispatcher.dispatch({ type: "GUILD_SCHEDULED_EVENT_USER_ADD", userId: c29910_0, guildId: guildId2, guildEventId: guildEventId2, guildEventExceptionId: guildEventExceptionId2, response: c29910_1.response }); throw c29910_2; } catch (r87) { r8 = r87; c26146_2 = r87; if (c26146_3 === 0) { break; } } } } throw r8; } return void 0; } return r71; }, updateRsvp: async function updateRsvp(c16355_0, c16355_1, c16355_2, c16355_3, c16355_4) { const _this = this; let c26147_2; let c26147_3 = 0; let c29911_0, c29911_1; L14: { try { if (getExistingRsvp(c16355_0, c16355_1) != null) { c26147_3 = 1; await _this.deleteRsvpForGuildEvent(c16355_0, c16355_1, c16355_2); if (c16355_4 != null) { c16355_4(); } c26147_3 = 0; } else { c26147_3 = 2; await _this.createRsvpForGuildEvent(c16355_0, c16355_1, c16355_2, c16355_3); if (c16355_4 != null) { c16355_4(); } c26147_3 = 0; } } catch ($e) { const r34 = $e; let r8 = r34; c26147_2 = r34; let r35 = c26147_3; if (r35 !== 0) { while (true) { if (r35 === 1) { try { const r108 = c26147_2; c26147_3 = 0; c29911_0 = r108; if (c16355_4 == null) { break L14; } c16355_4(c29911_0); break L14; } catch (r105) { r8 = r105; c26147_2 = r105; r35 = c26147_3; if (r35 === 0) { break; } } } else { try { const r96 = c26147_2; c26147_3 = 0; c29911_1 = r96; if (c16355_4 == null) { break L14; } c16355_4(c29911_1); break L14; } catch (r93) { r8 = r93; c26147_2 = r93; r35 = c26147_3; if (r35 === 0) { break; } } } } } throw r8; } } }, fetchUsersForGuildEvent: async function fetchUsersForGuildEvent(c16356_0, c16356_1, c16356_2, r6 = MAX_RSVP_USER_DISPLAY_COUNT) { const MAX_RSVP_USER_DISPLAY_COUNT2 = r6; let c26148_1; let c29912_0; L13: { c26148_1 = void 0; c29912_0 = void 0; if (c16356_0 == null) { break L13; } if (c16356_2 == null) { break L13; } c29912_0 = await HTTP.get({ url: Endpoints.GUILD_EVENT_USERS(c16356_2, c16356_0, c16356_1), query: { limit: MAX_RSVP_USER_DISPLAY_COUNT2, with_member: true }, rejectWithError: rejectWithMigratedError() }); Dispatcher.dispatch({ type: "GUILD_SCHEDULED_EVENT_USERS_FETCH_SUCCESS", guildEventId: c16356_0, guildScheduledEventUsers: c29912_0.body, guildId: c16356_2, guildEventExceptionId: c16356_1 }); return c29912_0.body.users; } return []; }, createGuildEventException: ({ original_scheduled_start_time, scheduled_start_time, scheduled_end_time, is_canceled }, a1, a2) => HTTP.post({ url: Endpoints.GUILD_EVENT_EXCEPTIONS(a1, a2), body: { original_scheduled_start_time, scheduled_start_time, scheduled_end_time, is_canceled }, rejectWithError: rejectWithMigratedError() }), updateGuildEventException: ({ scheduled_start_time, scheduled_end_time, is_canceled }, a1, a2, a3) => HTTP.patch({ url: Endpoints.GUILD_EVENT_EXCEPTION(a1, a2, a3), body: { scheduled_start_time, scheduled_end_time, is_canceled }, rejectWithError: rejectWithMigratedError() }), deleteGuildEventException: (a0, a1, a2) => HTTP.del({ url: Endpoints.GUILD_EVENT_EXCEPTION(a0, a1, a2), rejectWithError: rejectWithMigratedError() }), deleteRecurrence: function deleteRecurrence(a0, a1, a2, a3) { if (a3 != null) { return this.updateGuildEventException({ scheduled_start_time: a3.scheduled_start_time, scheduled_end_time: a3.scheduled_end_time, is_canceled: true }, a0, a1, a2); } return this.createGuildEventException({ original_scheduled_start_time: new Date(SnowflakeUtils.extractTimestamp(a2)).toISOString(), is_canceled: true }, a0, a1); } }; export default r29;