UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

57 lines (56 loc) • 2.94 kB
import { a as defineChannelAliasMigration, d as normalizeAccountId, u as DEFAULT_ACCOUNT_ID } from "./runtime-doctor-migrations-JGL9tD-z.js"; import { t as createLegacyWebhookListenerDoctorContract } from "./legacy-webhook-listener-migration-s2MKGUiS.js"; import { _ as createAccountListHelpers, v as hasConfiguredAccountValue } from "./account-core-u1qUW4Od.js"; //#region extensions/nextcloud-talk/configured-state.ts const { listAccountIds: listNextcloudTalkAccountIds, resolveDefaultAccountId: resolveDefaultNextcloudTalkAccountId, resolveAccountConfig: mergeNextcloudTalkAccountConfig } = createAccountListHelpers("nextcloud-talk", { normalizeAccountId, omitKeys: ["defaultAccount"], hasImplicitDefaultAccount: (e) => hasConfiguredNextcloudAccount(e.channels?.["nextcloud-talk"], process.env) }); function hasConfiguredNextcloudAccount(e, t) { return Boolean(e?.baseUrl?.trim() && (hasConfiguredAccountValue(e.botSecret) || hasConfiguredAccountValue(e.botSecretFile) || hasConfiguredAccountValue(t.NEXTCLOUD_TALK_BOT_SECRET))); } /** Require a Nextcloud server plus its account-owned bot credential. */ function hasConfiguredNextcloudTalkChannelState(e) { const t = e.cfg.channels?.["nextcloud-talk"]; if (t?.enabled === false) return false; if ((t?.accounts?.["default"])?.enabled !== false) { if (hasConfiguredNextcloudAccount(mergeNextcloudTalkAccountConfig(e.cfg, "default"), e.env ?? process.env)) return true; } return Object.entries(t?.accounts ?? {}).some(([t, n]) => t !== "default" && n.enabled !== false && hasConfiguredNextcloudAccount(mergeNextcloudTalkAccountConfig(e.cfg, t), {})); } //#endregion //#region extensions/nextcloud-talk/src/doctor-contract.ts const webhookContract = createLegacyWebhookListenerDoctorContract({ channelKey: "nextcloud-talk", defaultHost: "0.0.0.0", defaultPort: 8788 }); const { historicalWebhookListener } = webhookContract; const streamingAliasMigration = defineChannelAliasMigration({ channelId: "nextcloud-talk", streaming: { defaultMode: "partial", deliveryOnly: true }, accountStreamingReplacesRoot: true }); const legacyConfigRules = [...webhookContract.legacyConfigRules, ...streamingAliasMigration.legacyConfigRules]; function normalizeHistoricalWebhookConfig({ cfg: e }) { return { ...webhookContract.normalizeCompatibilityConfig({ cfg: e }), historicalWebhookAccountIds: !hasConfiguredNextcloudTalkChannelState({ cfg: e }) ? [] : listNextcloudTalkAccountIds(e).filter((t) => mergeNextcloudTalkAccountConfig(e, t).enabled !== false) }; } function normalizeCompatibilityConfig({ cfg: e }) { const t = normalizeHistoricalWebhookConfig({ cfg: e }); return { ...streamingAliasMigration.normalizeChannelConfig({ cfg: t.config, changes: t.changes }), historicalWebhookAccountIds: t.historicalWebhookAccountIds }; } //#endregion export { historicalWebhookListener, legacyConfigRules, normalizeCompatibilityConfig, normalizeHistoricalWebhookConfig };