mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-13 06:30:45 +08:00
feat(whatsapp): add access modes
This commit is contained in:
parent
b0e2c266c5
commit
9b65dd3d6b
15 changed files with 860 additions and 162 deletions
|
|
@ -9,6 +9,7 @@ export const WHATSAPP_ENDPOINTS = Object.freeze({
|
|||
cancelProvisioning: 'provision.cancel',
|
||||
reconnectBot: 'bot.reconnect',
|
||||
deleteBot: 'bot.delete',
|
||||
setAccessPolicy: 'bot.access-policy.set',
|
||||
setWorkspace: 'bot.workspace.set',
|
||||
setAgentPreset: SET_AGENT_PRESET_ENDPOINT,
|
||||
});
|
||||
|
|
@ -86,6 +87,16 @@ function normalizeBot(value) {
|
|||
state: connected ? 'connected' : state,
|
||||
workspace: text(value.workspace, '', 4_096),
|
||||
agentPreset: normalizeAgentPresetId(value.agentPreset),
|
||||
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)
|
||||
)))]
|
||||
: [],
|
||||
},
|
||||
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