mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 20:38:27 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -17,11 +17,17 @@ const EVENT_SCOPE_GUARDS: Record<string, string[]> = {
|
||||
|
||||
function hasEventScope(client: GatewayWsClient, event: string): boolean {
|
||||
const required = EVENT_SCOPE_GUARDS[event];
|
||||
if (!required) return true;
|
||||
if (!required) {
|
||||
return true;
|
||||
}
|
||||
const role = client.connect.role ?? "operator";
|
||||
if (role !== "operator") return false;
|
||||
if (role !== "operator") {
|
||||
return false;
|
||||
}
|
||||
const scopes = Array.isArray(client.connect.scopes) ? client.connect.scopes : [];
|
||||
if (scopes.includes(ADMIN_SCOPE)) return true;
|
||||
if (scopes.includes(ADMIN_SCOPE)) {
|
||||
return true;
|
||||
}
|
||||
return required.some((scope) => scopes.includes(scope));
|
||||
}
|
||||
|
||||
@@ -56,9 +62,13 @@ export function createGatewayBroadcaster(params: { clients: Set<GatewayWsClient>
|
||||
}
|
||||
logWs("out", "event", logMeta);
|
||||
for (const c of params.clients) {
|
||||
if (!hasEventScope(c, event)) continue;
|
||||
if (!hasEventScope(c, event)) {
|
||||
continue;
|
||||
}
|
||||
const slow = c.socket.bufferedAmount > MAX_BUFFERED_BYTES;
|
||||
if (slow && opts?.dropIfSlow) continue;
|
||||
if (slow && opts?.dropIfSlow) {
|
||||
continue;
|
||||
}
|
||||
if (slow) {
|
||||
try {
|
||||
c.socket.close(1008, "slow consumer");
|
||||
|
||||
Reference in New Issue
Block a user