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