mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 08:30:42 +00:00
fix: honor live matrix dm scope for owner pins
This commit is contained in:
@@ -23,6 +23,7 @@ type MatrixHandlerTestHarnessOptions = {
|
||||
accountId?: string;
|
||||
accountConfig?: MatrixConfig;
|
||||
cfg?: unknown;
|
||||
liveCfg?: unknown;
|
||||
client?: Partial<MatrixClient>;
|
||||
runtime?: RuntimeEnv;
|
||||
logger?: RuntimeLogger;
|
||||
@@ -192,7 +193,7 @@ export function createMatrixHandlerTestHarness(
|
||||
} as never,
|
||||
core: {
|
||||
config: {
|
||||
current: () => cfgForHandler,
|
||||
current: () => options.liveCfg ?? cfgForHandler,
|
||||
},
|
||||
channel: {
|
||||
pairing: {
|
||||
|
||||
@@ -228,6 +228,50 @@ describe("matrix monitor handler pairing account scope", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("uses live dmScope when deciding whether to pin main DM route updates", async () => {
|
||||
const startupCfg = {
|
||||
session: { dmScope: "main" },
|
||||
channels: {
|
||||
matrix: {
|
||||
dm: { allowFrom: ["@owner:example.org"] },
|
||||
},
|
||||
},
|
||||
};
|
||||
const liveCfg = {
|
||||
session: { dmScope: "per-channel-peer" },
|
||||
channels: {
|
||||
matrix: {
|
||||
dm: { allowFrom: ["@owner:example.org"] },
|
||||
},
|
||||
},
|
||||
};
|
||||
const { handler, recordInboundSession } = createMatrixHandlerTestHarness({
|
||||
cfg: startupCfg,
|
||||
liveCfg,
|
||||
dmPolicy: "allowlist",
|
||||
allowFrom: ["@owner:example.org"],
|
||||
allowFromResolvedEntries: [{ input: "@owner:example.org", id: "@owner:example.org" }],
|
||||
isDirectMessage: true,
|
||||
});
|
||||
|
||||
await handler(
|
||||
"!dm:example.org",
|
||||
createMatrixTextMessageEvent({
|
||||
eventId: "$owner-dm-live-scope",
|
||||
sender: "@owner:example.org",
|
||||
body: "hello",
|
||||
}),
|
||||
);
|
||||
|
||||
expect(recordInboundSession).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
updateLastRoute: expect.objectContaining({
|
||||
mainDmOwnerPin: undefined,
|
||||
}),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("sends pairing reminders for pending requests with cooldown", async () => {
|
||||
vi.useFakeTimers();
|
||||
vi.setSystemTime(new Date("2026-03-01T10:00:00.000Z"));
|
||||
|
||||
@@ -1956,7 +1956,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
|
||||
},
|
||||
});
|
||||
return resolvePinnedMainDmOwnerFromAllowlist({
|
||||
dmScope: cfg.session?.dmScope,
|
||||
dmScope: livePinnedCfg.session?.dmScope,
|
||||
allowFrom: livePinnedDmAllowFrom,
|
||||
normalizeEntry: normalizeMatrixUserId,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user