mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-16 11:41:08 +00:00
fix(matrix): allow per-room reuse without stored account metadata
This commit is contained in:
@@ -655,6 +655,7 @@ Matrix is extension-backed and configured under `channels.matrix`.
|
||||
- `sessionFilter`: optional session key patterns (substring or regex).
|
||||
- `target`: where to send approval prompts. `"dm"` (default), `"channel"` (originating room), or `"both"`.
|
||||
- Per-account overrides: `channels.matrix.accounts.<id>.execApprovals`.
|
||||
- `channels.matrix.dm.sessionScope` controls how Matrix DMs group into sessions: `per-user` (default) shares by routed peer, while `per-room` isolates each DM room.
|
||||
- Matrix status probes and live directory lookups use the same proxy policy as runtime traffic.
|
||||
- Full Matrix configuration, targeting rules, and setup examples are documented in [Matrix](/channels/matrix).
|
||||
|
||||
|
||||
@@ -304,4 +304,61 @@ describe("resolveMatrixOutboundSessionRoute", () => {
|
||||
to: "room:!dm:example.org",
|
||||
});
|
||||
});
|
||||
|
||||
it("reuses the current DM room when stored account metadata is missing", () => {
|
||||
const storePath = createTempStore({
|
||||
"agent:main:matrix:channel:!dm:example.org": {
|
||||
sessionId: "sess-1",
|
||||
updatedAt: Date.now(),
|
||||
chatType: "direct",
|
||||
origin: {
|
||||
chatType: "direct",
|
||||
from: "matrix:@alice:example.org",
|
||||
to: "room:!dm:example.org",
|
||||
},
|
||||
deliveryContext: {
|
||||
channel: "matrix",
|
||||
to: "room:!dm:example.org",
|
||||
},
|
||||
},
|
||||
});
|
||||
const cfg = {
|
||||
session: {
|
||||
store: storePath,
|
||||
},
|
||||
channels: {
|
||||
matrix: {
|
||||
defaultAccount: "ops",
|
||||
accounts: {
|
||||
ops: {
|
||||
dm: {
|
||||
sessionScope: "per-room",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
} satisfies OpenClawConfig;
|
||||
|
||||
const route = resolveMatrixOutboundSessionRoute({
|
||||
cfg,
|
||||
agentId: "main",
|
||||
currentSessionKey: "agent:main:matrix:channel:!dm:example.org",
|
||||
target: "@alice:example.org",
|
||||
resolvedTarget: {
|
||||
to: "@alice:example.org",
|
||||
kind: "user",
|
||||
source: "normalized",
|
||||
},
|
||||
});
|
||||
|
||||
expect(route).toMatchObject({
|
||||
sessionKey: "agent:main:matrix:channel:!dm:example.org",
|
||||
baseSessionKey: "agent:main:matrix:channel:!dm:example.org",
|
||||
peer: { kind: "channel", id: "!dm:example.org" },
|
||||
chatType: "direct",
|
||||
from: "matrix:@alice:example.org",
|
||||
to: "room:!dm:example.org",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -55,7 +55,7 @@ function resolveMatrixCurrentDmRoomId(params: {
|
||||
if (!currentSession) {
|
||||
return undefined;
|
||||
}
|
||||
if (!currentSession.accountId || currentSession.accountId !== params.accountId) {
|
||||
if (currentSession.accountId && currentSession.accountId !== params.accountId) {
|
||||
return undefined;
|
||||
}
|
||||
if (!currentSession.directUserId || currentSession.directUserId !== params.targetUserId) {
|
||||
|
||||
Reference in New Issue
Block a user