refactor: dedupe extension lowercase helpers

This commit is contained in:
Peter Steinberger
2026-04-07 22:09:21 +01:00
parent a44a26f0a0
commit 2187b19d7e
17 changed files with 41 additions and 35 deletions

View File

@@ -1,3 +1,4 @@
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime";
import { createFeishuClient } from "./client.js";
import type { ResolvedFeishuAccount } from "./types.js";
@@ -37,7 +38,7 @@ function correctFeishuScopeInUrl(url: string): string {
}
function shouldSuppressPermissionErrorNotice(permissionError: FeishuPermissionError): boolean {
const message = permissionError.message.toLowerCase();
const message = normalizeLowercaseStringOrEmpty(permissionError.message);
return IGNORED_PERMISSION_SCOPE_TOKENS.some((token) => message.includes(token));
}

View File

@@ -1,3 +1,4 @@
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime";
import type { RuntimeEnv } from "../runtime-api.js";
import { probeFeishu } from "./probe.js";
import type { ResolvedFeishuAccount } from "./types.js";
@@ -33,13 +34,12 @@ export type FeishuMonitorBotIdentity = {
};
function isTimeoutErrorMessage(message: string | undefined): boolean {
return !!(
message?.toLowerCase().includes("timeout") || message?.toLowerCase().includes("timed out")
);
const lower = normalizeLowercaseStringOrEmpty(message);
return lower.includes("timeout") || lower.includes("timed out");
}
function isAbortErrorMessage(message: string | undefined): boolean {
return message?.toLowerCase().includes("aborted") ?? false;
return normalizeLowercaseStringOrEmpty(message).includes("aborted");
}
export async function fetchBotIdentityForMonitor(

View File

@@ -12,6 +12,7 @@ import {
type OpenClawConfig,
type SecretInput,
} from "openclaw/plugin-sdk/setup";
import { normalizeOptionalLowercaseString } from "openclaw/plugin-sdk/text-runtime";
import {
inspectFeishuCredentials,
resolveDefaultFeishuAccountId,
@@ -102,7 +103,7 @@ function isFeishuConfigured(cfg: OpenClawConfig, accountId?: string | null): boo
return false;
}
const rec = value as Record<string, unknown>;
const source = normalizeString(rec.source)?.toLowerCase();
const source = normalizeOptionalLowercaseString(normalizeString(rec.source));
const id = normalizeString(rec.id);
if (source === "env" && id) {
return Boolean(normalizeString(process.env[id]));