diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2022-08-12 11:36:39 +0200 |
---|---|---|
committer | TheArcaneBrony <myrainbowdash949@gmail.com> | 2022-08-13 21:57:51 +0200 |
commit | 10bd81274722823f875ba31eaf5fc670bfb22ceb (patch) | |
tree | 9c622935ca99e791f7ee1e27ef67c9d23388012a /gateway/src | |
parent | Move some invite defaults into class (diff) | |
download | server-10bd81274722823f875ba31eaf5fc670bfb22ceb.tar.xz |
Split schemas into files in util
Diffstat (limited to 'gateway/src')
-rw-r--r-- | gateway/src/opcodes/Identify.ts | 2 | ||||
-rw-r--r-- | gateway/src/opcodes/LazyRequest.ts | 3 | ||||
-rw-r--r-- | gateway/src/opcodes/PresenceUpdate.ts | 3 | ||||
-rw-r--r-- | gateway/src/opcodes/VoiceStateUpdate.ts | 2 | ||||
-rw-r--r-- | gateway/src/schema/Activity.ts | 51 | ||||
-rw-r--r-- | gateway/src/schema/Identify.ts | 89 | ||||
-rw-r--r-- | gateway/src/schema/LazyRequest.ts | 19 | ||||
-rw-r--r-- | gateway/src/schema/VoiceStateUpdateSchema.ts | 15 |
8 files changed, 4 insertions, 180 deletions
diff --git a/gateway/src/opcodes/Identify.ts b/gateway/src/opcodes/Identify.ts index ce4385a3..e62c1570 100644 --- a/gateway/src/opcodes/Identify.ts +++ b/gateway/src/opcodes/Identify.ts @@ -19,12 +19,12 @@ import { MemberPrivateProjection, PresenceUpdateEvent, UserSettings, + IdentifySchema, } from "@fosscord/util"; import { Send } from "../util/Send"; import { CLOSECODES, OPCODES } from "../util/Constants"; import { genSessionId } from "../util/SessionUtils"; import { setupListener } from "../listener/listener"; -import { IdentifySchema } from "../schema/Identify"; // import experiments from "./experiments.json"; const experiments: any = []; import { check } from "./instanceOf"; diff --git a/gateway/src/opcodes/LazyRequest.ts b/gateway/src/opcodes/LazyRequest.ts index 5ba65cdd..cd0586de 100644 --- a/gateway/src/opcodes/LazyRequest.ts +++ b/gateway/src/opcodes/LazyRequest.ts @@ -1,5 +1,4 @@ -import { getPermission, listenEvent, Member, Role, getOrInitialiseDatabase } from "@fosscord/util"; -import { LazyRequest } from "../schema/LazyRequest"; +import { getPermission, listenEvent, Member, Role, getOrInitialiseDatabase, LazyRequest } from "@fosscord/util"; import { Send } from "../util/Send"; import { OPCODES } from "../util/Constants"; import { WebSocket, Payload, handlePresenceUpdate } from "@fosscord/gateway"; diff --git a/gateway/src/opcodes/PresenceUpdate.ts b/gateway/src/opcodes/PresenceUpdate.ts index 415df6ee..f31c9161 100644 --- a/gateway/src/opcodes/PresenceUpdate.ts +++ b/gateway/src/opcodes/PresenceUpdate.ts @@ -1,6 +1,5 @@ import { WebSocket, Payload } from "@fosscord/gateway"; -import { emitEvent, PresenceUpdateEvent, Session, User } from "@fosscord/util"; -import { ActivitySchema } from "../schema/Activity"; +import { ActivitySchema, emitEvent, PresenceUpdateEvent, Session, User } from "@fosscord/util"; import { check } from "./instanceOf"; export async function onPresenceUpdate(this: WebSocket, { d }: Payload) { diff --git a/gateway/src/opcodes/VoiceStateUpdate.ts b/gateway/src/opcodes/VoiceStateUpdate.ts index 845a75c0..73f73565 100644 --- a/gateway/src/opcodes/VoiceStateUpdate.ts +++ b/gateway/src/opcodes/VoiceStateUpdate.ts @@ -1,4 +1,3 @@ -import { VoiceStateUpdateSchema } from "../schema/VoiceStateUpdateSchema"; import { Payload, WebSocket } from "@fosscord/gateway"; import { genVoiceToken } from "../util/SessionUtils"; import { check } from "./instanceOf"; @@ -10,6 +9,7 @@ import { VoiceServerUpdateEvent, VoiceState, VoiceStateUpdateEvent, + VoiceStateUpdateSchema, } from "@fosscord/util"; import { OrmUtils } from "@fosscord/util"; import { Region } from "@fosscord/util/src/config"; diff --git a/gateway/src/schema/Activity.ts b/gateway/src/schema/Activity.ts deleted file mode 100644 index e18f66c8..00000000 --- a/gateway/src/schema/Activity.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { Activity, Status } from "@fosscord/util"; - -export const ActivitySchema = { - afk: Boolean, - status: String, - $activities: [ - { - name: String, - type: Number, - $url: String, - $created_at: Date, - $timestamps: { - $start: Number, - $end: Number, - }, - $application_id: String, - $details: String, - $state: String, - $emoji: { - $name: String, - $id: String, - $animated: Boolean, - }, - $party: { - $id: String, - $size: [Number, Number], - }, - $assets: { - $large_image: String, - $large_text: String, - $small_image: String, - $small_text: String, - }, - $secrets: { - $join: String, - $spectate: String, - $match: String, - }, - $instance: Boolean, - $flags: String, - }, - ], - $since: Number, // unix time (in milliseconds) of when the client went idle, or null if the client is not idle -}; - -export interface ActivitySchema { - afk: boolean; - status: Status; - activities?: Activity[]; - since?: number; // unix time (in milliseconds) of when the client went idle, or null if the client is not idle -} diff --git a/gateway/src/schema/Identify.ts b/gateway/src/schema/Identify.ts deleted file mode 100644 index 21141321..00000000 --- a/gateway/src/schema/Identify.ts +++ /dev/null @@ -1,89 +0,0 @@ -import { ActivitySchema } from "./Activity"; - -export const IdentifySchema = { - token: String, - $intents: BigInt, // discord uses a Integer for bitfields we use bigints tho. | instanceOf will automatically convert the Number to a BigInt - $properties: Object, - // { - // // discord uses $ in the property key for bots, so we need to double prefix it, because instanceOf treats $ (prefix) as a optional key - // $os: String, - // $os_arch: String, - // $browser: String, - // $device: String, - // $$os: String, - // $$browser: String, - // $$device: String, - // $browser_user_agent: String, - // $browser_version: String, - // $os_version: String, - // $referrer: String, - // $$referrer: String, - // $referring_domain: String, - // $$referring_domain: String, - // $referrer_current: String, - // $referring_domain_current: String, - // $release_channel: String, - // $client_build_number: Number, - // $client_event_source: String, - // $client_version: String, - // $system_locale: String, - // $window_manager: String, - // $distro: String, - // }, - $presence: ActivitySchema, - $compress: Boolean, - $large_threshold: Number, - $shard: [BigInt, BigInt], - $guild_subscriptions: Boolean, - $capabilities: Number, - $client_state: { - $guild_hashes: Object, - $highest_last_message_id: String, - $read_state_version: Number, - $user_guild_settings_version: Number, - $user_settings_version: undefined, - }, - $v: Number, - $version: Number, -}; - -export interface IdentifySchema { - token: string; - properties: { - // bruh discord really uses $ in the property key, so we need to double prefix it, because instanceOf treats $ (prefix) as a optional key - os?: string; - os_atch?: string; - browser?: string; - device?: string; - $os?: string; - $browser?: string; - $device?: string; - browser_user_agent?: string; - browser_version?: string; - os_version?: string; - referrer?: string; - referring_domain?: string; - referrer_current?: string; - referring_domain_current?: string; - release_channel?: "stable" | "dev" | "ptb" | "canary"; - client_build_number?: number; - client_event_source?: any; - client_version?: string; - system_locale?: string; - }; - intents?: bigint; // discord uses a Integer for bitfields we use bigints tho. | instanceOf will automatically convert the Number to a BigInt - presence?: ActivitySchema; - compress?: boolean; - large_threshold?: number; - shard?: [bigint, bigint]; - guild_subscriptions?: boolean; - capabilities?: number; - client_state?: { - guild_hashes?: any; - highest_last_message_id?: string; - read_state_version?: number; - user_guild_settings_version?: number; - user_settings_version?: number; - }; - v?: number; -} diff --git a/gateway/src/schema/LazyRequest.ts b/gateway/src/schema/LazyRequest.ts deleted file mode 100644 index 1fe658bb..00000000 --- a/gateway/src/schema/LazyRequest.ts +++ /dev/null @@ -1,19 +0,0 @@ -export interface LazyRequest { - guild_id: string; - channels?: Record<string, [number, number][]>; - activities?: boolean; - threads?: boolean; - typing?: true; - members?: any[]; - thread_member_lists?: any[]; -} - -export const LazyRequest = { - guild_id: String, - $activities: Boolean, - $channels: Object, - $typing: Boolean, - $threads: Boolean, - $members: [] as any[], - $thread_member_lists: [] as any[], -}; diff --git a/gateway/src/schema/VoiceStateUpdateSchema.ts b/gateway/src/schema/VoiceStateUpdateSchema.ts deleted file mode 100644 index 9efa191e..00000000 --- a/gateway/src/schema/VoiceStateUpdateSchema.ts +++ /dev/null @@ -1,15 +0,0 @@ -export const VoiceStateUpdateSchema = { - $guild_id: String, - $channel_id: String, - self_mute: Boolean, - self_deaf: Boolean, - self_video: Boolean, -}; - -export interface VoiceStateUpdateSchema { - guild_id?: string; - channel_id?: string; - self_mute: boolean; - self_deaf: boolean; - self_video: boolean; -} |