mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-17 20:21:13 +00:00
refactor: dedupe extension lowercase helpers
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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]));
|
||||
|
||||
Reference in New Issue
Block a user