move Schema from util to gateway
This commit is contained in:
parent
38757c60e1
commit
caafbc606c
@ -1,8 +1,9 @@
|
|||||||
import { CLOSECODES, Payload } from "../util/Constants";
|
import { CLOSECODES, Payload } from "../util/Constants";
|
||||||
import WebSocket from "../util/WebSocket";
|
import WebSocket from "../util/WebSocket";
|
||||||
import { checkToken, IdentifySchema } from "fosscord-server-util";
|
import { checkToken } from "fosscord-server-util";
|
||||||
import { setupListener } from "../listener/listener";
|
import { setupListener } from "../listener/listener";
|
||||||
import { instanceOf } from "lambert-server";
|
import { instanceOf } from "lambert-server";
|
||||||
|
import { IdentifySchema } from "../schema/Identify";
|
||||||
|
|
||||||
export async function onIdentify(this: WebSocket, data: Payload) {
|
export async function onIdentify(this: WebSocket, data: Payload) {
|
||||||
try {
|
try {
|
||||||
|
81
src/schema/Activity.ts
Normal file
81
src/schema/Activity.ts
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
import { EmojiSchema } from "./Emoji";
|
||||||
|
|
||||||
|
export const ActivitySchema = {
|
||||||
|
afk: Boolean,
|
||||||
|
status: String,
|
||||||
|
$activities: [
|
||||||
|
{
|
||||||
|
name: String, // the activity's name
|
||||||
|
type: Number, // activity type // TODO: check if its between range 0-5
|
||||||
|
$url: String, // stream url, is validated when type is 1
|
||||||
|
$created_at: Number, // unix timestamp of when the activity was added to the user's session
|
||||||
|
$timestamps: {
|
||||||
|
// unix timestamps for start and/or end of the game
|
||||||
|
start: Number,
|
||||||
|
end: Number,
|
||||||
|
},
|
||||||
|
$application_id: BigInt, // application id for the game
|
||||||
|
$details: String,
|
||||||
|
$State: String,
|
||||||
|
$emoji: EmojiSchema,
|
||||||
|
$party: {
|
||||||
|
$id: String,
|
||||||
|
$size: [Number], // used to show the party's current and maximum size // TODO: array length 2
|
||||||
|
},
|
||||||
|
$assets: {
|
||||||
|
$large_image: String, // the id for a large asset of the activity, usually a snowflake
|
||||||
|
$large_text: String, // text displayed when hovering over the large image of the activity
|
||||||
|
$small_image: String, // the id for a small asset of the activity, usually a snowflake
|
||||||
|
$small_text: String, // text displayed when hovering over the small image of the activity
|
||||||
|
},
|
||||||
|
$secrets: {
|
||||||
|
$join: String, // the secret for joining a party
|
||||||
|
$spectate: String, // the secret for spectating a game
|
||||||
|
$match: String, // the secret for a specific instanced match
|
||||||
|
},
|
||||||
|
$instance: Boolean,
|
||||||
|
flags: BigInt, // activity flags OR d together, describes what the payload includes
|
||||||
|
},
|
||||||
|
],
|
||||||
|
$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: string;
|
||||||
|
activities?: [
|
||||||
|
{
|
||||||
|
name: string; // the activity's name
|
||||||
|
type: number; // activity type // TODO: check if its between range 0-5
|
||||||
|
url?: string; // stream url, is validated when type is 1
|
||||||
|
created_at?: number; // unix timestamp of when the activity was added to the user's session
|
||||||
|
timestamps?: {
|
||||||
|
// unix timestamps for start and/or end of the game
|
||||||
|
start: number;
|
||||||
|
end: number;
|
||||||
|
};
|
||||||
|
application_id?: bigint; // application id for the game
|
||||||
|
details?: string;
|
||||||
|
State?: string;
|
||||||
|
emoji?: EmojiSchema;
|
||||||
|
party?: {
|
||||||
|
id?: string;
|
||||||
|
size?: [number]; // used to show the party's current and maximum size // TODO: array length 2
|
||||||
|
};
|
||||||
|
assets?: {
|
||||||
|
large_image?: string; // the id for a large asset of the activity, usually a snowflake
|
||||||
|
large_text?: string; // text displayed when hovering over the large image of the activity
|
||||||
|
small_image?: string; // the id for a small asset of the activity, usually a snowflake
|
||||||
|
small_text?: string; // text displayed when hovering over the small image of the activity
|
||||||
|
};
|
||||||
|
secrets?: {
|
||||||
|
join?: string; // the secret for joining a party
|
||||||
|
spectate?: string; // the secret for spectating a game
|
||||||
|
match?: string; // the secret for a specific instanced match
|
||||||
|
};
|
||||||
|
instance?: boolean;
|
||||||
|
flags: bigint; // activity flags OR d together, describes what the payload includes
|
||||||
|
}
|
||||||
|
];
|
||||||
|
since?: number; // unix time (in milliseconds) of when the client went idle, or null if the client is not idle
|
||||||
|
}
|
11
src/schema/Emoji.ts
Normal file
11
src/schema/Emoji.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
export const EmojiSchema = {
|
||||||
|
name: String, // the name of the emoji
|
||||||
|
$id: BigInt, // the id of the emoji
|
||||||
|
animated: Boolean, // whether this emoji is animated
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface EmojiSchema {
|
||||||
|
name: string;
|
||||||
|
id?: bigint;
|
||||||
|
animated: Boolean;
|
||||||
|
}
|
33
src/schema/Identify.ts
Normal file
33
src/schema/Identify.ts
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
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: {
|
||||||
|
// 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,
|
||||||
|
$$browser: String,
|
||||||
|
$$device: String,
|
||||||
|
},
|
||||||
|
$presence: ActivitySchema,
|
||||||
|
$compress: Boolean,
|
||||||
|
$large_threshold: Number,
|
||||||
|
$shard: [Number],
|
||||||
|
$guild_subscriptions: Boolean,
|
||||||
|
};
|
||||||
|
|
||||||
|
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;
|
||||||
|
$$browser: string;
|
||||||
|
$$device: 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?: [number];
|
||||||
|
guild_subscriptions?: boolean;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user