mirror of https://github.com/openclaw/openclaw.git
fix(matrix): keep local promotion on unknown room info
This commit is contained in:
parent
59df972693
commit
6638d4b505
|
|
@ -6,6 +6,9 @@ import type { MatrixRoomInfo } from "./room-info.js";
|
|||
|
||||
type DirectRoomTrackerOptions = {
|
||||
canPromoteRecentInvite?: (roomId: string) => boolean | Promise<boolean>;
|
||||
shouldKeepLocallyPromotedDirectRoom?:
|
||||
| ((roomId: string) => boolean | undefined | Promise<boolean | undefined>)
|
||||
| undefined;
|
||||
};
|
||||
|
||||
const hoisted = vi.hoisted(() => {
|
||||
|
|
@ -555,6 +558,25 @@ describe("monitorMatrixProvider", () => {
|
|||
|
||||
await expect(trackerOpts.canPromoteRecentInvite("!room:example.org")).resolves.toBe(false);
|
||||
});
|
||||
|
||||
it("treats unresolved room metadata as indeterminate for local promotion revalidation", async () => {
|
||||
await startMonitorAndAbortAfterStartup();
|
||||
|
||||
const trackerOpts = hoisted.createDirectRoomTracker.mock.calls[0]?.[1];
|
||||
if (!trackerOpts?.shouldKeepLocallyPromotedDirectRoom) {
|
||||
throw new Error("local promotion revalidation callback was not wired");
|
||||
}
|
||||
|
||||
hoisted.getRoomInfo.mockResolvedValueOnce({
|
||||
altAliases: [],
|
||||
nameResolved: false,
|
||||
aliasesResolved: false,
|
||||
});
|
||||
|
||||
await expect(
|
||||
trackerOpts.shouldKeepLocallyPromotedDirectRoom("!room:example.org"),
|
||||
).resolves.toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("matrix plugin registration", () => {
|
||||
|
|
|
|||
|
|
@ -226,9 +226,13 @@ export async function monitorMatrixProvider(opts: MonitorMatrixOpts = {}): Promi
|
|||
}),
|
||||
shouldKeepLocallyPromotedDirectRoom: async (roomId) => {
|
||||
try {
|
||||
const roomInfo = await getRoomInfo(roomId, { includeAliases: true });
|
||||
if (!roomInfo.nameResolved || !roomInfo.aliasesResolved) {
|
||||
return undefined;
|
||||
}
|
||||
return shouldPromoteRecentInviteRoom({
|
||||
roomId,
|
||||
roomInfo: await getRoomInfo(roomId, { includeAliases: true }),
|
||||
roomInfo,
|
||||
rooms: roomsConfig,
|
||||
});
|
||||
} catch (err) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue