🐛 fix identify
This commit is contained in:
parent
13cbf7bd88
commit
22e8e83ab9
@ -13,7 +13,6 @@ import {
|
|||||||
EVENTEnum,
|
EVENTEnum,
|
||||||
} from "@fosscord/server-util";
|
} from "@fosscord/server-util";
|
||||||
import { setupListener } from "../listener/listener";
|
import { setupListener } from "../listener/listener";
|
||||||
import { instanceOf } from "lambert-server";
|
|
||||||
import { IdentifySchema } from "../schema/Identify";
|
import { IdentifySchema } from "../schema/Identify";
|
||||||
import { Send } from "../util/Send";
|
import { Send } from "../util/Send";
|
||||||
import experiments from "./experiments.json";
|
import experiments from "./experiments.json";
|
||||||
@ -25,7 +24,7 @@ import { check } from "./instanceOf";
|
|||||||
|
|
||||||
export async function onIdentify(this: WebSocket, data: Payload) {
|
export async function onIdentify(this: WebSocket, data: Payload) {
|
||||||
clearTimeout(this.readyTimeout);
|
clearTimeout(this.readyTimeout);
|
||||||
if (!check.call(this, IdentifySchema, data.d)) return;
|
check.call(this, IdentifySchema, data.d);
|
||||||
|
|
||||||
const identify: IdentifySchema = data.d;
|
const identify: IdentifySchema = data.d;
|
||||||
|
|
||||||
|
@ -4,11 +4,15 @@ import WebSocket from "../util/WebSocket";
|
|||||||
|
|
||||||
export function check(this: WebSocket, schema: any, data: any) {
|
export function check(this: WebSocket, schema: any, data: any) {
|
||||||
try {
|
try {
|
||||||
if (instanceOf(schema, data) !== true) throw "invalid";
|
const error = instanceOf(schema, data);
|
||||||
|
if (error !== true) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
// invalid payload
|
// invalid payload
|
||||||
this.close(CLOSECODES.Decode_error);
|
this.close(CLOSECODES.Decode_error);
|
||||||
return false;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user