mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 08:40:44 +00:00
BlueBubbles: move outbound session routing behind plugin boundary
This commit is contained in:
@@ -29,6 +29,7 @@ import {
|
|||||||
DEFAULT_ACCOUNT_ID,
|
DEFAULT_ACCOUNT_ID,
|
||||||
PAIRING_APPROVED_MESSAGE,
|
PAIRING_APPROVED_MESSAGE,
|
||||||
} from "./runtime-api.js";
|
} from "./runtime-api.js";
|
||||||
|
import { resolveBlueBubblesOutboundSessionRoute } from "./session-route.js";
|
||||||
import { blueBubblesSetupAdapter } from "./setup-core.js";
|
import { blueBubblesSetupAdapter } from "./setup-core.js";
|
||||||
import { blueBubblesSetupWizard } from "./setup-surface.js";
|
import { blueBubblesSetupWizard } from "./setup-surface.js";
|
||||||
import {
|
import {
|
||||||
@@ -140,6 +141,7 @@ export const bluebubblesPlugin: ChannelPlugin<ResolvedBlueBubblesAccount> = {
|
|||||||
},
|
},
|
||||||
messaging: {
|
messaging: {
|
||||||
normalizeTarget: normalizeBlueBubblesMessagingTarget,
|
normalizeTarget: normalizeBlueBubblesMessagingTarget,
|
||||||
|
resolveOutboundSessionRoute: (params) => resolveBlueBubblesOutboundSessionRoute(params),
|
||||||
targetResolver: {
|
targetResolver: {
|
||||||
looksLikeId: looksLikeBlueBubblesTargetId,
|
looksLikeId: looksLikeBlueBubblesTargetId,
|
||||||
hint: "<handle|chat_guid:GUID|chat_id:ID|chat_identifier:ID>",
|
hint: "<handle|chat_guid:GUID|chat_id:ID|chat_identifier:ID>",
|
||||||
|
|||||||
37
extensions/bluebubbles/src/session-route.ts
Normal file
37
extensions/bluebubbles/src/session-route.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import {
|
||||||
|
buildChannelOutboundSessionRoute,
|
||||||
|
stripChannelTargetPrefix,
|
||||||
|
type ChannelOutboundSessionRouteParams,
|
||||||
|
} from "openclaw/plugin-sdk/core";
|
||||||
|
import { parseBlueBubblesTarget } from "./targets.js";
|
||||||
|
|
||||||
|
export function resolveBlueBubblesOutboundSessionRoute(params: ChannelOutboundSessionRouteParams) {
|
||||||
|
const stripped = stripChannelTargetPrefix(params.target, "bluebubbles");
|
||||||
|
if (!stripped) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const parsed = parseBlueBubblesTarget(stripped);
|
||||||
|
const isGroup =
|
||||||
|
parsed.kind === "chat_id" || parsed.kind === "chat_guid" || parsed.kind === "chat_identifier";
|
||||||
|
const peerId =
|
||||||
|
parsed.kind === "chat_id"
|
||||||
|
? String(parsed.chatId)
|
||||||
|
: parsed.kind === "chat_guid"
|
||||||
|
? parsed.chatGuid
|
||||||
|
: parsed.kind === "chat_identifier"
|
||||||
|
? parsed.chatIdentifier
|
||||||
|
: parsed.to;
|
||||||
|
return buildChannelOutboundSessionRoute({
|
||||||
|
cfg: params.cfg,
|
||||||
|
agentId: params.agentId,
|
||||||
|
channel: "bluebubbles",
|
||||||
|
accountId: params.accountId,
|
||||||
|
peer: {
|
||||||
|
kind: isGroup ? "group" : "direct",
|
||||||
|
id: peerId,
|
||||||
|
},
|
||||||
|
chatType: isGroup ? "group" : "direct",
|
||||||
|
from: isGroup ? `group:${peerId}` : `bluebubbles:${peerId}`,
|
||||||
|
to: `bluebubbles:${stripped}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user