feat: socket target can also be string
This commit is contained in:
parent
b2ac1878b9
commit
63aea8dc27
1 changed files with 5 additions and 2 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue