refactor: dedupe messaging lowercase helpers

This commit is contained in:
Peter Steinberger
2026-04-07 15:20:23 +01:00
parent d43cc470c6
commit 4bcbb22678
15 changed files with 58 additions and 45 deletions

View File

@@ -1,6 +1,9 @@
import { resolveMergedAccountConfig } from "openclaw/plugin-sdk/account-resolution";
import { tryReadSecretFileSync } from "openclaw/plugin-sdk/channel-core";
import { normalizeOptionalString } from "openclaw/plugin-sdk/text-runtime";
import {
normalizeLowercaseStringOrEmpty,
normalizeOptionalString,
} from "openclaw/plugin-sdk/text-runtime";
import {
createAccountListHelpers,
DEFAULT_ACCOUNT_ID,
@@ -11,7 +14,7 @@ import { normalizeResolvedSecretInputString } from "./secret-input.js";
import type { CoreConfig, NextcloudTalkAccountConfig } from "./types.js";
function isTruthyEnvValue(value?: string): boolean {
const normalized = normalizeOptionalString(value)?.toLowerCase() ?? "";
const normalized = normalizeLowercaseStringOrEmpty(value);
return normalized === "true" || normalized === "1" || normalized === "yes" || normalized === "on";
}

View File

@@ -16,6 +16,7 @@ import {
createComputedAccountStatusAdapter,
createDefaultChannelRuntimeState,
} from "openclaw/plugin-sdk/status-helpers";
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime";
import {
listNextcloudTalkAccountIds,
resolveDefaultNextcloudTalkAccountId,
@@ -197,7 +198,7 @@ export const nextcloudTalkPlugin: ChannelPlugin<ResolvedNextcloudTalkAccount> =
message: "OpenClaw: your access has been approved.",
normalizeAllowEntry: createPairingPrefixStripper(
/^(nextcloud-talk|nc-talk|nc):/i,
(entry) => entry.toLowerCase(),
(entry) => normalizeLowercaseStringOrEmpty(entry),
),
notify: createLoggedPairingApprovalNotifier(
({ id }) => `[nextcloud-talk] User ${id} approved for pairing`,