diff --git a/src/services/webSocket.ts b/src/services/webSocket.ts index a125a3f9..2f9b42ff 100644 --- a/src/services/webSocket.ts +++ b/src/services/webSocket.ts @@ -40,8 +40,8 @@ export async function sendWebSocket( event: string, data: any, opts?: { - roles?: string[]; - userId?: string[]; + roles?: string | string[]; + userId?: string | string[]; }, ) { if (!io) initWebSocket(); @@ -59,6 +59,9 @@ export async function sendWebSocket( if (!user) continue; + if (typeof opts?.roles === "string") opts.roles = [opts.roles]; + if (typeof opts?.userId === "string") opts.userId = [opts.userId]; + if ( user.role?.some((v) => opts?.roles?.includes(v)) || opts?.userId?.some((v) => user.sub === v)