mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-09 05:20:46 +08:00
feat: add unified IM access policies
This commit is contained in:
parent
075d2713c1
commit
840e5aa857
89 changed files with 5573 additions and 1676 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import { normalizeAgentPresetCatalog, normalizeAgentPresetId, SET_AGENT_PRESET_ENDPOINT } from '../../agent-preset.js';
|
||||
import { normalizeLastMessageError } from '../../last-message-error.js';
|
||||
import { normalizeAccessPolicy } from '../../../../src/channels/shared/access-policy.mjs';
|
||||
import { normalizeContextEnhancementConfig } from '../../../../src/channels/shared/context-enhancement.mjs';
|
||||
|
||||
export const WHATSAPP_RPC_CHANNEL = '/whatsapp';
|
||||
|
|
@ -91,16 +92,9 @@ function normalizeBot(value) {
|
|||
workspace: text(value.workspace, '', 4_096),
|
||||
agentPreset: normalizeAgentPresetId(value.agentPreset),
|
||||
contextEnhancement: normalizeContextEnhancementConfig(value.contextEnhancement),
|
||||
accessPolicy: {
|
||||
accessMode: ['self-only', 'private-allowlist', 'open'].includes(
|
||||
value.accessPolicy?.accessMode,
|
||||
) ? value.accessPolicy.accessMode : 'self-only',
|
||||
allowedNumbers: Array.isArray(value.accessPolicy?.allowedNumbers)
|
||||
? [...new Set(value.accessPolicy.allowedNumbers.filter((entry) => (
|
||||
typeof entry === 'string' && /^[1-9]\d{4,14}$/.test(entry)
|
||||
)))]
|
||||
: [],
|
||||
},
|
||||
...(Object.hasOwn(value, 'accessPolicy')
|
||||
? { accessPolicy: normalizeAccessPolicy(value.accessPolicy) }
|
||||
: {}),
|
||||
bot: {
|
||||
name: text(value.bot?.name, 'WhatsApp机器人', 100),
|
||||
idMasked: text(value.bot?.idMasked, 'WhatsApp账号', 140),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue