Skip to content

Commit b14538c

Browse files
author
damaozi
committed
fix(line): remove redundant group:/room: prefix from buildPeerId (#21907)
1 parent 1b886e7 commit b14538c

File tree

3 files changed

+78
-2
lines changed

3 files changed

+78
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Docs: https://docs.openclaw.ai
1212

1313
### Fixes
1414

15+
- LINE: remove redundant `group:`/`room:` prefix from `buildPeerId` so peer-based binding routes match the raw group/room ID as documented. (#21907)
16+
1517
- macOS/Build: default release packaging to `BUNDLE_ID=ai.openclaw.mac` in `scripts/package-mac-dist.sh`, so Sparkle feed URL is retained and auto-update no longer fails with an empty appcast feed. (#19750) thanks @loganprit.
1618

1719
- Signal/Outbound: preserve case for Base64 group IDs during outbound target normalization so cross-context routing and policy checks no longer break when group IDs include uppercase characters. (#5578) Thanks @heyhudson.

src/line/bot-message-context.test.ts

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,78 @@ describe("buildLineMessageContext", () => {
8383
expect(context?.ctxPayload.OriginatingTo).toBe("line:group:group-2");
8484
expect(context?.ctxPayload.To).toBe("line:group:group-2");
8585
});
86+
87+
it("group peer binding matches raw groupId without prefix (#21907)", async () => {
88+
const groupId = "Cc7e3bece1234567890abcdef";
89+
const bindingCfg: OpenClawConfig = {
90+
session: { store: storePath },
91+
agents: {
92+
list: [{ id: "main" }, { id: "line-group-agent" }],
93+
},
94+
bindings: [
95+
{
96+
agentId: "line-group-agent",
97+
match: { channel: "line", peer: { kind: "group", id: groupId } },
98+
},
99+
],
100+
};
101+
102+
const event = {
103+
type: "message",
104+
message: { id: "msg-1", type: "text", text: "hello" },
105+
replyToken: "reply-token",
106+
timestamp: Date.now(),
107+
source: { type: "group", groupId, userId: "user-1" },
108+
mode: "active",
109+
webhookEventId: "evt-1",
110+
deliveryContext: { isRedelivery: false },
111+
} as MessageEvent;
112+
113+
const context = await buildLineMessageContext({
114+
event,
115+
allMedia: [],
116+
cfg: bindingCfg,
117+
account,
118+
});
119+
expect(context).not.toBeNull();
120+
expect(context!.route.agentId).toBe("line-group-agent");
121+
expect(context!.route.matchedBy).toBe("binding.peer");
122+
});
123+
124+
it("room peer binding matches raw roomId without prefix (#21907)", async () => {
125+
const roomId = "Rr1234567890abcdef";
126+
const bindingCfg: OpenClawConfig = {
127+
session: { store: storePath },
128+
agents: {
129+
list: [{ id: "main" }, { id: "line-room-agent" }],
130+
},
131+
bindings: [
132+
{
133+
agentId: "line-room-agent",
134+
match: { channel: "line", peer: { kind: "group", id: roomId } },
135+
},
136+
],
137+
};
138+
139+
const event = {
140+
type: "message",
141+
message: { id: "msg-2", type: "text", text: "hello" },
142+
replyToken: "reply-token",
143+
timestamp: Date.now(),
144+
source: { type: "room", roomId, userId: "user-2" },
145+
mode: "active",
146+
webhookEventId: "evt-2",
147+
deliveryContext: { isRedelivery: false },
148+
} as MessageEvent;
149+
150+
const context = await buildLineMessageContext({
151+
event,
152+
allMedia: [],
153+
cfg: bindingCfg,
154+
account,
155+
});
156+
expect(context).not.toBeNull();
157+
expect(context!.route.agentId).toBe("line-room-agent");
158+
expect(context!.route.matchedBy).toBe("binding.peer");
159+
});
86160
});

src/line/bot-message-context.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ export function getLineSourceInfo(source: EventSource): LineSourceInfo {
5151

5252
function buildPeerId(source: EventSource): string {
5353
if (source.type === "group" && source.groupId) {
54-
return `group:${source.groupId}`;
54+
return source.groupId;
5555
}
5656
if (source.type === "room" && source.roomId) {
57-
return `room:${source.roomId}`;
57+
return source.roomId;
5858
}
5959
if (source.type === "user" && source.userId) {
6060
return source.userId;

0 commit comments

Comments
 (0)