mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-27 09:21:35 +07:00
refactor: simplify builder pairing adapters
This commit is contained in:
@@ -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: {
|
||||
|
||||
@@ -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: {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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: {
|
||||
|
||||
@@ -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"),
|
||||
|
||||
Reference in New Issue
Block a user