fix: align bluebubbles outbound group sessions

This commit is contained in:
Peter Steinberger
2026-01-24 12:22:49 +00:00
parent 0dca8acbe2
commit 49c518951c
4 changed files with 77 additions and 44 deletions

View File

@@ -68,6 +68,18 @@ describe("resolveOutboundSessionRoute", () => {
expect(route?.sessionKey).toBe("agent:main:dm:alice");
});
it("strips chat_* prefixes for BlueBubbles group session keys", async () => {
const route = await resolveOutboundSessionRoute({
cfg: baseConfig,
channel: "bluebubbles",
agentId: "main",
target: "chat_guid:ABC123",
});
expect(route?.sessionKey).toBe("agent:main:bluebubbles:group:abc123");
expect(route?.from).toBe("group:ABC123");
});
it("treats Zalo Personal DM targets as direct sessions", async () => {
const cfg = { session: { dmScope: "per-channel-peer" } } as ClawdbotConfig;
const route = await resolveOutboundSessionRoute({

View File

@@ -545,9 +545,13 @@ function resolveBlueBubblesSession(
lower.startsWith("chat_guid:") ||
lower.startsWith("chat_identifier:") ||
lower.startsWith("group:");
const peerId = isGroup
const rawPeerId = isGroup
? stripKindPrefix(stripped)
: stripped.replace(/^(imessage|sms|auto):/i, "");
// BlueBubbles inbound group ids omit chat_* prefixes; strip them to align sessions.
const peerId = isGroup
? rawPeerId.replace(/^(chat_id|chat_guid|chat_identifier):/i, "")
: rawPeerId;
if (!peerId) return null;
const peer: RoutePeer = {
kind: isGroup ? "group" : "dm",