refactor: align channel chatType

This commit is contained in:
Peter Steinberger
2026-01-17 04:13:06 +00:00
parent 388b2bce01
commit 87cecd0268
7 changed files with 36 additions and 48 deletions

View File

@@ -19,7 +19,7 @@ export function normalizeMediaUnderstandingChatType(raw?: string | null): string
if (!value) return undefined;
if (value === "dm" || value === "direct_message" || value === "private") return "direct";
if (value === "groups") return "group";
if (value === "channel") return "room";
if (value === "room") return "channel";
return value;
}
@@ -33,7 +33,7 @@ export function resolveMediaUnderstandingScope(params: {
if (!scope) return "allow";
const channel = normalizeMatch(params.channel);
const chatType = normalizeMatch(params.chatType);
const chatType = normalizeMediaUnderstandingChatType(params.chatType) ?? normalizeMatch(params.chatType);
const sessionKey = normalizeMatch(params.sessionKey) ?? "";
for (const rule of scope.rules ?? []) {
@@ -41,7 +41,8 @@ export function resolveMediaUnderstandingScope(params: {
const action = normalizeDecision(rule.action) ?? "allow";
const match = rule.match ?? {};
const matchChannel = normalizeMatch(match.channel);
const matchChatType = normalizeMatch(match.chatType);
const matchChatType =
normalizeMediaUnderstandingChatType(match.chatType) ?? normalizeMatch(match.chatType);
const matchPrefix = normalizeMatch(match.keyPrefix);
if (matchChannel && matchChannel !== channel) continue;