mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 21:58:26 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -36,7 +36,9 @@ export const normalizeAllowFromWithStore = (params: {
|
||||
|
||||
export const firstDefined = <T>(...values: Array<T | undefined>) => {
|
||||
for (const value of values) {
|
||||
if (typeof value !== "undefined") return value;
|
||||
if (typeof value !== "undefined") {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
@@ -47,11 +49,19 @@ export const isSenderAllowed = (params: {
|
||||
senderUsername?: string;
|
||||
}) => {
|
||||
const { allow, senderId, senderUsername } = params;
|
||||
if (!allow.hasEntries) return true;
|
||||
if (allow.hasWildcard) return true;
|
||||
if (senderId && allow.entries.includes(senderId)) return true;
|
||||
if (!allow.hasEntries) {
|
||||
return true;
|
||||
}
|
||||
if (allow.hasWildcard) {
|
||||
return true;
|
||||
}
|
||||
if (senderId && allow.entries.includes(senderId)) {
|
||||
return true;
|
||||
}
|
||||
const username = senderUsername?.toLowerCase();
|
||||
if (!username) return false;
|
||||
if (!username) {
|
||||
return false;
|
||||
}
|
||||
return allow.entriesLower.some((entry) => entry === username || entry === `@${username}`);
|
||||
};
|
||||
|
||||
@@ -64,12 +74,16 @@ export const resolveSenderAllowMatch = (params: {
|
||||
if (allow.hasWildcard) {
|
||||
return { allowed: true, matchKey: "*", matchSource: "wildcard" };
|
||||
}
|
||||
if (!allow.hasEntries) return { allowed: false };
|
||||
if (!allow.hasEntries) {
|
||||
return { allowed: false };
|
||||
}
|
||||
if (senderId && allow.entries.includes(senderId)) {
|
||||
return { allowed: true, matchKey: senderId, matchSource: "id" };
|
||||
}
|
||||
const username = senderUsername?.toLowerCase();
|
||||
if (!username) return { allowed: false };
|
||||
if (!username) {
|
||||
return { allowed: false };
|
||||
}
|
||||
const entry = allow.entriesLower.find(
|
||||
(candidate) => candidate === username || candidate === `@${username}`,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user