refactor: simplify builder pairing adapters

This commit is contained in:
Peter Steinberger
2026-03-22 22:40:44 +00:00
parent 18c4a00b6f
commit 3a949646da
5 changed files with 49 additions and 33 deletions

View File

@@ -190,9 +190,12 @@ export const imessagePlugin: ChannelPlugin<ResolvedIMessageAccount, IMessageProb
},
},
pairing: {
idLabel: "imessageSenderId",
notifyApproval: async ({ id }) =>
await (await loadIMessageChannelRuntime()).notifyIMessageApproval(id),
text: {
idLabel: "imessageSenderId",
message: "OpenClaw: your access has been approved.",
notify: async ({ id }) =>
await (await loadIMessageChannelRuntime()).notifyIMessageApproval(id),
},
},
security: imessageSecurityAdapter,
outbound: {

View File

@@ -410,11 +410,14 @@ export const mattermostPlugin: ChannelPlugin<ResolvedMattermostAccount> = create
},
},
pairing: {
idLabel: "mattermostUserId",
normalizeAllowEntry: (entry) => normalizeAllowEntry(entry),
notifyApproval: createLoggedPairingApprovalNotifier(
({ id }) => `[mattermost] User ${id} approved for pairing`,
),
text: {
idLabel: "mattermostUserId",
message: "OpenClaw: your access has been approved.",
normalizeAllowEntry: (entry) => normalizeAllowEntry(entry),
notify: createLoggedPairingApprovalNotifier(
({ id }) => `[mattermost] User ${id} approved for pairing`,
),
},
},
threading: {
scopedAccountReplyToMode: {

View File

@@ -291,13 +291,17 @@ export const nextcloudTalkPlugin: ChannelPlugin<ResolvedNextcloudTalkAccount> =
},
},
pairing: {
idLabel: "nextcloudUserId",
normalizeAllowEntry: createPairingPrefixStripper(/^(nextcloud-talk|nc-talk|nc):/i, (entry) =>
entry.toLowerCase(),
),
notifyApproval: createLoggedPairingApprovalNotifier(
({ id }) => `[nextcloud-talk] User ${id} approved for pairing`,
),
text: {
idLabel: "nextcloudUserId",
message: "OpenClaw: your access has been approved.",
normalizeAllowEntry: createPairingPrefixStripper(
/^(nextcloud-talk|nc-talk|nc):/i,
(entry) => entry.toLowerCase(),
),
notify: createLoggedPairingApprovalNotifier(
({ id }) => `[nextcloud-talk] User ${id} approved for pairing`,
),
},
},
security: {
resolveDmPolicy: resolveNextcloudTalkDmPolicy,

View File

@@ -398,20 +398,23 @@ export const nostrPlugin: ChannelPlugin<ResolvedNostrAccount> = createChatChanne
},
},
pairing: {
idLabel: "nostrPubkey",
normalizeAllowEntry: (entry) => {
try {
return normalizePubkey(entry.trim().replace(/^nostr:/i, ""));
} catch {
return entry.trim();
}
},
notifyApproval: async ({ id }) => {
// Get the default account's bus and send approval message
const bus = activeBuses.get(DEFAULT_ACCOUNT_ID);
if (bus) {
await bus.sendDm(id, "Your pairing request has been approved!");
}
text: {
idLabel: "nostrPubkey",
message: "Your pairing request has been approved!",
normalizeAllowEntry: (entry) => {
try {
return normalizePubkey(entry.trim().replace(/^nostr:/i, ""));
} catch {
return entry.trim();
}
},
notify: async ({ id, message }) => {
// Get the default account's bus and send approval message
const bus = activeBuses.get(DEFAULT_ACCOUNT_ID);
if (bus) {
await bus.sendDm(id, message);
}
},
},
},
security: {

View File

@@ -241,10 +241,13 @@ export const zaloPlugin: ChannelPlugin<ResolvedZaloAccount, ZaloProbeResult> =
collectWarnings: collectZaloSecurityWarnings,
},
pairing: {
idLabel: "zaloUserId",
normalizeAllowEntry: (entry) => entry.trim().replace(/^(zalo|zl):/i, ""),
notifyApproval: async (params) =>
await (await loadZaloChannelRuntime()).notifyZaloPairingApproval(params),
text: {
idLabel: "zaloUserId",
message: "Your pairing request has been approved.",
normalizeAllowEntry: (entry) => entry.trim().replace(/^(zalo|zl):/i, ""),
notify: async (params) =>
await (await loadZaloChannelRuntime()).notifyZaloPairingApproval(params),
},
},
threading: {
resolveReplyToMode: createStaticReplyToModeResolver("off"),