diff --git a/extensions/matrix/src/matrix/monitor/index.ts b/extensions/matrix/src/matrix/monitor/index.ts index 5e2192bc9..0da860e98 100644 --- a/extensions/matrix/src/matrix/monitor/index.ts +++ b/extensions/matrix/src/matrix/monitor/index.ts @@ -184,18 +184,21 @@ export async function monitorMatrixProvider(opts: MonitorMatrixOpts = {}): Promi aliases: roomAliases, name: roomName, }); + const roomMatchMeta = `matchKey=${roomConfigInfo.matchKey ?? "none"} matchSource=${ + roomConfigInfo.matchSource ?? "none" + }`; if (roomConfigInfo.config && !roomConfigInfo.allowed) { - logVerbose(`matrix: room disabled room=${roomId}`); + logVerbose(`matrix: room disabled room=${roomId} (${roomMatchMeta})`); return; } if (groupPolicy === "allowlist") { if (!roomConfigInfo.allowlistConfigured) { - logVerbose("matrix: drop room message (no allowlist)"); + logVerbose(`matrix: drop room message (no allowlist, ${roomMatchMeta})`); return; } if (!roomConfigInfo.config) { - logVerbose("matrix: drop room message (not in allowlist)"); + logVerbose(`matrix: drop room message (not in allowlist, ${roomMatchMeta})`); return; } } @@ -252,7 +255,9 @@ export async function monitorMatrixProvider(opts: MonitorMatrixOpts = {}): Promi userName: senderName, }); if (!userAllowed) { - logVerbose(`matrix: blocked sender ${senderId} (room users allowlist)`); + logVerbose( + `matrix: blocked sender ${senderId} (room users allowlist, ${roomMatchMeta})`, + ); return; } } diff --git a/extensions/matrix/src/matrix/monitor/rooms.ts b/extensions/matrix/src/matrix/monitor/rooms.ts index 9628b5f27..fe5bbc167 100644 --- a/extensions/matrix/src/matrix/monitor/rooms.ts +++ b/extensions/matrix/src/matrix/monitor/rooms.ts @@ -8,6 +8,8 @@ export type MatrixRoomConfigResolved = { allowed: boolean; allowlistConfigured: boolean; config?: MatrixRoomConfig; + matchKey?: string; + matchSource?: "direct" | "wildcard"; }; export function resolveMatrixRoomConfig(params: { @@ -25,12 +27,20 @@ export function resolveMatrixRoomConfig(params: { ...params.aliases, params.name ?? "", ); - const { entry: matched, wildcardEntry } = resolveChannelEntryMatch({ + const { entry: matched, key: matchedKey, wildcardEntry, wildcardKey } = resolveChannelEntryMatch({ entries: rooms, keys: candidates, wildcardKey: "*", }); const resolved = matched ?? wildcardEntry; const allowed = resolved ? resolved.enabled !== false && resolved.allow !== false : false; - return { allowed, allowlistConfigured, config: resolved }; + const matchKey = matchedKey ?? wildcardKey; + const matchSource = matched ? "direct" : wildcardEntry ? "wildcard" : undefined; + return { + allowed, + allowlistConfigured, + config: resolved, + matchKey, + matchSource, + }; }