// Metro module 13575 (f13576). import ApplicationStore from "../../../applications/ApplicationStore"; import RunningGameStore_native from "../../../game_detection/RunningGameStore.native"; import { getGuildIconURL } from "../../../../records/GuildRecord"; import ApplicationStreamingStore from "../../../../stores/ApplicationStreamingStore"; import ChannelStore from "../../../../stores/ChannelStore"; import GuildMemberStore from "../../../../stores/GuildMemberStore"; import GuildStore from "../../../../stores/GuildStore"; import MediaEngineStore from "../../../../stores/MediaEngineStore"; import RTCConnectionStore from "../../../../stores/RTCConnectionStore"; import UserStore from "../../../../stores/UserStore"; import VoiceStateStore from "../../../../stores/VoiceStateStore"; import * as _Constants from "../../Constants"; import { ApplicationFlags, RPCErrors, RPCEvents } from "../../../../Constants"; import createRpcJoiSchemaObject from "../../helpers/createRpcJoiSchemaObject"; import { hasMessageReadPermission, transformVoiceState, getVoiceConnectionState } from "../../RPCHelpers"; import RPCError from "../../RPCError"; import { userCannotSeeNSFWContent } from "../../../age_gate/AgeGateUtils"; import { OAuth2Scopes } from "../../../../_bundle/Module8174"; import Module12 from "../../../../_bundle/Module12"; import { activityInstanceConnectedParticipantsUpdateEvent } from "../../helpers/activityInstanceConnectedParticipants"; import { has, deserialize } from "../../../../_bundle/HighLow"; import shallowEqual from "../../../../_bundle/shallowEqual"; import transformUser from "../../helpers/transformUser"; import transformGuildMember from "../../helpers/transformGuildMember"; import transformApplication from "../../helpers/transformApplication"; const messageEventsValidation = function messageEventsValidation(a0) { return createRpcJoiSchemaObject(a0).required().keys({ channel_id: a0.string().required() }); }; const messageEvents = function messageEvents(a0) { const channel_id4 = a0.args.channel_id; const socket = a0.socket; const channel4 = ChannelStore.getChannel(channel_id4); if (channel4 != null && hasMessageReadPermission(channel4, socket.application.id, socket.authorization.scopes)) { if (userCannotSeeNSFWContent(channel4)) { throw new RPCError({ errorCode: RPCErrors.INVALID_CHANNEL }, `Invalid nsfw channel id: ${channel4.id}`); } return void 0; } throw new RPCError({ errorCode: RPCErrors.INVALID_CHANNEL }, `Invalid channel id: ${channel_id4}`); }; const speakingEventsValidation = function speakingEventsValidation(a0) { return createRpcJoiSchemaObject(a0).keys({ channel_id: a0.string().allow(null) }); }; const speakingEvents = function speakingEvents(a0) { const channel_id4 = a0.args.channel_id; if (channel_id4 != null && ChannelStore.getChannel(channel_id4) == null) { throw new RPCError({ errorCode: RPCErrors.INVALID_CHANNEL }, `Invalid channel id: ${channel_id4}`); } }; const { RPC_AUTHENTICATED_SCOPE, RPC_LOCAL_SCOPE, RPC_SCOPE_CONFIG } = _Constants; const r54 = {}; r54[RPCEvents.GUILD_STATUS] = { scope: OAuth2Scopes.RPC, validation: (a0) => createRpcJoiSchemaObject(a0).required().keys({ guild_id: a0.string().required() }), handler: (a0) => { const guild_id = a0.args.guild_id; if (GuildStore.getGuild(guild_id) == null) { throw new RPCError({ errorCode: RPCErrors.INVALID_GUILD }, `Invalid guild id: ${guild_id}`); } return ({ prevState, dispatch: dispatch4 }) => { const guild = GuildStore.getGuild(guild_id); if (guild != null) { let icon_url = getGuildIconURL(guild, 128); if (icon_url == null) { icon_url = null; } const r18 = { guild: { id: guild.id, name: guild.name, icon_url }, online: 0 }; if (!Module12.isEqual(prevState, r18)) { dispatch4(r18); } return r18; } }; } }; const VOICE_STATE_CREATE = RPCEvents.VOICE_STATE_CREATE; const scope = {}; scope[RPC_SCOPE_CONFIG.ANY] = [OAuth2Scopes.RPC, OAuth2Scopes.RPC_VOICE_READ]; r54[VOICE_STATE_CREATE] = { scope, validation: (a0) => createRpcJoiSchemaObject(a0).required().keys({ channel_id: a0.string().required() }), handler: (a0) => { const channel_id = a0.args.channel_id; if (ChannelStore.getChannel(channel_id) == null) { throw new RPCError({ errorCode: RPCErrors.INVALID_CHANNEL }, `Invalid channel id: ${channel_id}`); } return ({ prevState, dispatch }) => { let guildId; guildId = void 0; const channel = ChannelStore.getChannel(channel_id); if (channel != null) { guildId = channel.getGuildId(); const r21 = Object.values(VoiceStateStore.getVoiceStatesForChannel(channel.id)); if (prevState) { Module12.differenceBy(r21, prevState, (a0) => a0.userId).forEach((item) => dispatch(transformVoiceState(guildId, channel.id, item))); } return r21; } }; } }; const VOICE_STATE_DELETE = RPCEvents.VOICE_STATE_DELETE; const scope2 = {}; scope2[RPC_SCOPE_CONFIG.ANY] = [OAuth2Scopes.RPC, OAuth2Scopes.RPC_VOICE_READ]; r54[VOICE_STATE_DELETE] = { scope: scope2, validation: (a0) => createRpcJoiSchemaObject(a0).required().keys({ channel_id: a0.string().required() }), handler: (a0) => { const channel_id2 = a0.args.channel_id; if (ChannelStore.getChannel(channel_id2) == null) { throw new RPCError({ errorCode: RPCErrors.INVALID_CHANNEL }, `Invalid channel id: ${channel_id2}`); } return ({ prevState, dispatch: dispatch2 }) => { let guildId2; guildId2 = void 0; const channel2 = ChannelStore.getChannel(channel_id2); if (channel2 != null) { guildId2 = channel2.getGuildId(); const r21 = Object.values(VoiceStateStore.getVoiceStatesForChannel(channel2.id)); Module12.differenceBy(prevState, r21, (a0) => a0.userId).forEach((item) => dispatch2(transformVoiceState(guildId2, channel2.id, item))); return r21; } }; } }; const VOICE_STATE_UPDATE = RPCEvents.VOICE_STATE_UPDATE; const scope3 = {}; scope3[RPC_SCOPE_CONFIG.ANY] = [OAuth2Scopes.RPC, OAuth2Scopes.RPC_VOICE_READ]; r54[VOICE_STATE_UPDATE] = { scope: scope3, validation: (a0) => createRpcJoiSchemaObject(a0).required().keys({ channel_id: a0.string().required() }), handler: (a0) => { const channel_id3 = a0.args.channel_id; if (ChannelStore.getChannel(channel_id3) == null) { throw new RPCError({ errorCode: RPCErrors.INVALID_CHANNEL }, `Invalid channel id: ${channel_id3}`); } return ({ prevState, dispatch: dispatch3 }) => { let guildId3; guildId3 = void 0; const channel3 = ChannelStore.getChannel(channel_id3); if (channel3 != null) { guildId3 = channel3.getGuildId(); const r24 = Object.values(VoiceStateStore.getVoiceStatesForChannel(channel3.id)).map((item) => transformVoiceState(guildId3, channel3.id, item)); Module12.differenceWith(r24, prevState, Module12.isEqual).forEach((item) => dispatch3(item)); return r24; } }; } }; const VOICE_CONNECTION_STATUS = RPCEvents.VOICE_CONNECTION_STATUS; const scope4 = {}; scope4[RPC_SCOPE_CONFIG.ANY] = [OAuth2Scopes.RPC, OAuth2Scopes.RPC_VOICE_READ]; r54[VOICE_CONNECTION_STATUS] = { scope: scope4, handler: () => ({ prevState, dispatch: dispatch4 }) => { const r14 = { state: getVoiceConnectionState(RTCConnectionStore.getState()), hostname: RTCConnectionStore.getHostname(), pings: RTCConnectionStore.getPings(), average_ping: RTCConnectionStore.getAveragePing(), last_ping: RTCConnectionStore.getLastPing() }; if (!Module12.isEqual(r14, prevState)) { dispatch4(r14); } return r14; } }; r54[RPCEvents.MESSAGE_CREATE] = { scope: OAuth2Scopes.RPC, validation: messageEventsValidation, handler: messageEvents }; r54[RPCEvents.MESSAGE_UPDATE] = { scope: OAuth2Scopes.RPC, validation: messageEventsValidation, handler: messageEvents }; r54[RPCEvents.MESSAGE_DELETE] = { scope: OAuth2Scopes.RPC, validation: messageEventsValidation, handler: messageEvents }; const SPEAKING_START = RPCEvents.SPEAKING_START; const scope5 = {}; scope5[RPC_SCOPE_CONFIG.ANY] = [OAuth2Scopes.RPC, OAuth2Scopes.RPC_VOICE_READ, RPC_LOCAL_SCOPE]; r54[SPEAKING_START] = { scope: scope5, validation: speakingEventsValidation, handler: speakingEvents }; const SPEAKING_STOP = RPCEvents.SPEAKING_STOP; const scope6 = {}; scope6[RPC_SCOPE_CONFIG.ANY] = [OAuth2Scopes.RPC, OAuth2Scopes.RPC_VOICE_READ, RPC_LOCAL_SCOPE]; r54[SPEAKING_STOP] = { scope: scope6, validation: speakingEventsValidation, handler: speakingEvents }; r54[RPCEvents.GUILD_CREATE] = { scope: OAuth2Scopes.RPC, handler: () => {} }; r54[RPCEvents.CHANNEL_CREATE] = { scope: OAuth2Scopes.RPC, handler: () => {} }; const GAME_JOIN = RPCEvents.GAME_JOIN; const scope7 = {}; scope7[RPC_SCOPE_CONFIG.ANY] = [OAuth2Scopes.RPC, RPC_LOCAL_SCOPE]; r54[GAME_JOIN] = { scope: scope7, handler: () => {} }; const GAME_SPECTATE = RPCEvents.GAME_SPECTATE; const scope8 = {}; scope8[RPC_SCOPE_CONFIG.ANY] = [OAuth2Scopes.RPC, RPC_LOCAL_SCOPE]; r54[GAME_SPECTATE] = { scope: scope8, handler: () => {} }; const ACTIVITY_JOIN = RPCEvents.ACTIVITY_JOIN; const scope9 = {}; scope9[RPC_SCOPE_CONFIG.ANY] = [OAuth2Scopes.RPC, RPC_AUTHENTICATED_SCOPE, RPC_LOCAL_SCOPE]; r54[ACTIVITY_JOIN] = { scope: scope9, handler: () => {} }; const ACTIVITY_JOIN_REQUEST = RPCEvents.ACTIVITY_JOIN_REQUEST; const scope10 = {}; scope10[RPC_SCOPE_CONFIG.ANY] = [OAuth2Scopes.RPC, RPC_LOCAL_SCOPE]; r54[ACTIVITY_JOIN_REQUEST] = { scope: scope10, handler: () => {} }; const ACTIVITY_SPECTATE = RPCEvents.ACTIVITY_SPECTATE; const scope11 = {}; scope11[RPC_SCOPE_CONFIG.ANY] = [OAuth2Scopes.RPC, RPC_AUTHENTICATED_SCOPE, RPC_LOCAL_SCOPE]; r54[ACTIVITY_SPECTATE] = { scope: scope11, handler: () => {} }; const ACTIVITY_INVITE = RPCEvents.ACTIVITY_INVITE; const scope12 = {}; scope12[RPC_SCOPE_CONFIG.ANY] = [OAuth2Scopes.RPC, RPC_LOCAL_SCOPE]; r54[ACTIVITY_INVITE] = { scope: scope12, handler: () => {} }; r54[RPCEvents.ACTIVITY_PIP_MODE_UPDATE] = { scope: void 0, handler: () => {} }; r54[RPCEvents.ACTIVITY_LAYOUT_MODE_UPDATE] = { scope: void 0, handler: () => {} }; r54[RPCEvents.FRAME_LAYOUT_MODE_UPDATE] = { scope: void 0, handler: () => {} }; r54[RPCEvents.ACTIVITY_INSTANCE_PARTICIPANTS_UPDATE] = activityInstanceConnectedParticipantsUpdateEvent; const THERMAL_STATE_UPDATE = RPCEvents.THERMAL_STATE_UPDATE; const scope13 = {}; scope13[RPC_SCOPE_CONFIG.ANY] = [RPC_AUTHENTICATED_SCOPE]; r54[THERMAL_STATE_UPDATE] = { scope: scope13, handler: () => {} }; const ORIENTATION_UPDATE = RPCEvents.ORIENTATION_UPDATE; const scope14 = {}; scope14[RPC_SCOPE_CONFIG.ANY] = [RPC_AUTHENTICATED_SCOPE]; r54[ORIENTATION_UPDATE] = { scope: scope14, handler: () => {} }; r54[RPCEvents.VOICE_CHANNEL_SELECT] = { scope: OAuth2Scopes.RPC, handler: () => {} }; const NOTIFICATION_CREATE = RPCEvents.NOTIFICATION_CREATE; const scope15 = {}; scope15[RPC_SCOPE_CONFIG.ALL] = [OAuth2Scopes.RPC, OAuth2Scopes.RPC_NOTIFICATIONS_READ]; r54[NOTIFICATION_CREATE] = { scope: scope15, handler: () => {} }; r54[RPCEvents.RELATIONSHIP_UPDATE] = { scope: OAuth2Scopes.RELATIONSHIPS_READ, handler: (a0) => { let flags = a0.socket.application.flags; if (flags == null) { flags = 0; } if (has(deserialize(flags), deserialize(ApplicationFlags.DISABLE_RELATIONSHIPS_ACCESS))) { throw new RPCError({ errorCode: RPCErrors.INVALID_PERMISSIONS }, "Missing Permissions"); } } }; const CURRENT_USER_UPDATE = RPCEvents.CURRENT_USER_UPDATE; const scope16 = {}; scope16[RPC_SCOPE_CONFIG.ANY] = [RPC_LOCAL_SCOPE, OAuth2Scopes.IDENTIFY]; r54[CURRENT_USER_UPDATE] = { scope: scope16, handler: () => ({ prevState, dispatch: dispatch4 }) => { const r10 = { currentUser: UserStore.getCurrentUser() }; if (!(r10.currentUser == null || prevState != null && shallowEqual(r10, prevState))) { dispatch4(transformUser(r10.currentUser)); } return r10; } }; const CURRENT_GUILD_MEMBER_UPDATE = RPCEvents.CURRENT_GUILD_MEMBER_UPDATE; const scope17 = {}; scope17[RPC_SCOPE_CONFIG.ALL] = [OAuth2Scopes.IDENTIFY, OAuth2Scopes.GUILDS_MEMBERS_READ]; r54[CURRENT_GUILD_MEMBER_UPDATE] = { scope: scope17, handler: (a0) => { const guild_id2 = a0.args.guild_id; return ({ prevState, dispatch: dispatch4 }) => { const r11 = { currentGuildMember: GuildMemberStore.getSelfMember(guild_id2) }; if (!(r11.currentGuildMember == null || prevState != null && shallowEqual(r11, prevState))) { dispatch4(transformGuildMember(r11.currentGuildMember)); } return r11; }; } }; const ENTITLEMENT_CREATE = RPCEvents.ENTITLEMENT_CREATE; const scope18 = {}; scope18[RPC_SCOPE_CONFIG.ANY] = [RPC_LOCAL_SCOPE, RPC_AUTHENTICATED_SCOPE]; r54[ENTITLEMENT_CREATE] = { scope: scope18, handler: () => {} }; const ENTITLEMENT_DELETE = RPCEvents.ENTITLEMENT_DELETE; const scope19 = {}; scope19[RPC_SCOPE_CONFIG.ANY] = [RPC_LOCAL_SCOPE, RPC_AUTHENTICATED_SCOPE]; r54[ENTITLEMENT_DELETE] = { scope: scope19, handler: () => {} }; const SCREENSHARE_STATE_UPDATE = RPCEvents.SCREENSHARE_STATE_UPDATE; const scope20 = {}; scope20[RPC_SCOPE_CONFIG.ALL] = [RPC_LOCAL_SCOPE, OAuth2Scopes.RPC_SCREENSHARE_READ]; r54[SCREENSHARE_STATE_UPDATE] = { scope: scope20, handler: () => ({ prevState, dispatch: dispatch4 }) => { const streamerActiveStreamMetadata = ApplicationStreamingStore.getStreamerActiveStreamMetadata(); const r15 = streamerActiveStreamMetadata?.pid != null ? RunningGameStore_native.getGameForPID(streamerActiveStreamMetadata.pid) : null; const r19 = r15?.id != null ? ApplicationStore.getApplication(r15.id) : null; const r24 = r19 != null ? transformApplication(r19) : null; const sourceName = streamerActiveStreamMetadata?.sourceName; let pid = streamerActiveStreamMetadata?.pid; if (pid == null) { pid = null; } const r32 = { active: streamerActiveStreamMetadata != null, pid, application: r24 != null ? { name: sourceName } : null }; if (!Module12.isEqual(r32, prevState)) { dispatch4(r32); } return r32; } }; const VIDEO_STATE_UPDATE = RPCEvents.VIDEO_STATE_UPDATE; const scope21 = {}; scope21[RPC_SCOPE_CONFIG.ALL] = [RPC_LOCAL_SCOPE, OAuth2Scopes.RPC_VIDEO_READ]; r54[VIDEO_STATE_UPDATE] = { scope: scope21, handler: () => ({ prevState, dispatch: dispatch4 }) => { const r8 = { active: MediaEngineStore.isVideoEnabled() }; if (!Module12.isEqual(r8, prevState)) { dispatch4(r8); } return r8; } }; r54[RPCEvents.AUTHORIZE_REQUEST] = { scope: void 0, handler: () => {} }; export default r54;