mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-11 21:30:44 +08:00
Make WhatsApp member presets follow channel mapping by default.
Some checks failed
CI / Test, build, and verify package (push) Has been cancelled
Some checks failed
CI / Test, build, and verify package (push) Has been cancelled
Empty member/group Agent Preset now resolves to the bot workspace mapping (not Host global); settings label is Follow channel mapping, and /new createSession carries that mapping explicitly. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
f1d85d2985
commit
bcbe85fdb1
10 changed files with 182 additions and 131 deletions
|
|
@ -310,8 +310,9 @@ export function normalizeAccessGrant(input) {
|
|||
|
||||
/**
|
||||
* Resolve a chat-scoped Agent Preset override from the access grant.
|
||||
* Returns null when the chat should follow the bot-level (global) preset.
|
||||
* Priority: direct-member or group override > bot global (caller applies global).
|
||||
* Returns null when the chat should follow the bot/channel mapping preset
|
||||
* (workspaces.agentPresets[botId]), not the Host catalog default.
|
||||
* Priority: direct-member or group override > bot mapping (caller applies).
|
||||
* @param {unknown} grant
|
||||
* @param {{ kind?: string, phone?: string, senderId?: string, groupJid?: string, conversationId?: string }} [context]
|
||||
* @returns {string|null}
|
||||
|
|
@ -332,6 +333,25 @@ export function resolveAccessAgentPreset(grant, context = {}) {
|
|||
return normalizeOptionalAgentPresetId(member?.agentPreset) ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Member/group override, else the bot's workspace-mapped preset.
|
||||
* Does not fall through to Host catalog default — that is only used when the
|
||||
* bot mapping itself is empty (createSession omits agentPreset).
|
||||
* @param {unknown} grant
|
||||
* @param {{ kind?: string, phone?: string, senderId?: string, groupJid?: string, conversationId?: string }} [context]
|
||||
* @param {string|null|undefined} botAgentPreset
|
||||
* @returns {string|null}
|
||||
*/
|
||||
export function resolveChatAgentPreset(grant, context = {}, botAgentPreset = null) {
|
||||
const fromGrant = resolveAccessAgentPreset(grant, context);
|
||||
if (fromGrant) return fromGrant;
|
||||
if (typeof botAgentPreset === 'string') {
|
||||
const trimmed = botAgentPreset.trim();
|
||||
if (trimmed) return trimmed;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Seed owner phone as the first global admin when missing.
|
||||
* @param {object|null} grant
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue