refactor: dedupe channel extension readers

This commit is contained in:
Peter Steinberger
2026-04-07 07:45:05 +01:00
parent c19f322ff9
commit ce19b6bf6a
18 changed files with 75 additions and 49 deletions

View File

@@ -8,6 +8,7 @@ import {
} from "openclaw/plugin-sdk/account-resolution";
import { safeParseJsonWithSchema, safeParseWithSchema } from "openclaw/plugin-sdk/extension-shared";
import { isSecretRef } from "openclaw/plugin-sdk/secret-input";
import { normalizeOptionalString } from "openclaw/plugin-sdk/text-runtime";
import { z } from "zod";
import type { GoogleChatAccountConfig } from "./types.config.js";
@@ -103,7 +104,7 @@ function resolveCredentialsFromConfig(params: {
);
}
const file = account.serviceAccountFile?.trim();
const file = normalizeOptionalString(account.serviceAccountFile);
if (file) {
return { credentialsFile: file, source: "file" };
}
@@ -114,7 +115,7 @@ function resolveCredentialsFromConfig(params: {
if (envInline) {
return { credentials: envInline, source: "env" };
}
const envFile = process.env[ENV_SERVICE_ACCOUNT_FILE]?.trim();
const envFile = normalizeOptionalString(process.env[ENV_SERVICE_ACCOUNT_FILE]);
if (envFile) {
return { credentialsFile: envFile, source: "env" };
}
@@ -138,7 +139,7 @@ export function resolveGoogleChatAccount(params: {
return {
accountId,
name: merged.name?.trim() || undefined,
name: normalizeOptionalString(merged.name),
enabled,
config: merged,
credentialSource: credentials.source,

View File

@@ -1,4 +1,5 @@
import { resolveInboundMentionDecision } from "openclaw/plugin-sdk/channel-inbound";
import { normalizeOptionalString } from "openclaw/plugin-sdk/text-runtime";
import {
GROUP_POLICY_BLOCKED_LABEL,
createChannelPairingController,
@@ -397,6 +398,6 @@ export async function applyGoogleChatInboundAccessPolicy(params: {
ok: true,
commandAuthorized,
effectiveWasMentioned,
groupSystemPrompt: groupEntry?.systemPrompt?.trim() || undefined,
groupSystemPrompt: normalizeOptionalString(groupEntry?.systemPrompt),
};
}