mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-16 20:40:45 +00:00
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import type { ChannelAccountSnapshot, ChannelStatusIssue } from "openclaw/plugin-sdk/zalo";
|
|
import { coerceStatusIssueAccountId, readStatusIssueFields } from "../../shared/status-issues.js";
|
|
|
|
const ZALO_STATUS_FIELDS = ["accountId", "enabled", "configured", "dmPolicy"] as const;
|
|
|
|
export function collectZaloStatusIssues(accounts: ChannelAccountSnapshot[]): ChannelStatusIssue[] {
|
|
const issues: ChannelStatusIssue[] = [];
|
|
for (const entry of accounts) {
|
|
const account = readStatusIssueFields(entry, ZALO_STATUS_FIELDS);
|
|
if (!account) {
|
|
continue;
|
|
}
|
|
const accountId = coerceStatusIssueAccountId(account.accountId) ?? "default";
|
|
const enabled = account.enabled !== false;
|
|
const configured = account.configured === true;
|
|
if (!enabled || !configured) {
|
|
continue;
|
|
}
|
|
|
|
if (account.dmPolicy === "open") {
|
|
issues.push({
|
|
channel: "zalo",
|
|
accountId,
|
|
kind: "config",
|
|
message: 'Zalo dmPolicy is "open", allowing any user to message the bot without pairing.',
|
|
fix: 'Set channels.zalo.dmPolicy to "pairing" or "allowlist" to restrict access.',
|
|
});
|
|
}
|
|
}
|
|
return issues;
|
|
}
|