diff --git a/src/commands/doctor/channel-capabilities.ts b/src/commands/doctor/channel-capabilities.ts index b28542de257..138fbaff9b3 100644 --- a/src/commands/doctor/channel-capabilities.ts +++ b/src/commands/doctor/channel-capabilities.ts @@ -1,5 +1,6 @@ import { getBundledChannelPlugin } from "../../channels/plugins/bundled.js"; import { getChannelPlugin } from "../../channels/plugins/index.js"; +import { normalizeAnyChannelId } from "../../channels/registry.js"; import type { AllowFromMode } from "./shared/allow-from-mode.types.js"; export type DoctorGroupModel = "sender" | "route" | "hybrid"; @@ -18,12 +19,42 @@ const DEFAULT_DOCTOR_CHANNEL_CAPABILITIES: DoctorChannelCapabilities = { warnOnEmptyGroupSenderAllowlist: true, }; +const STATIC_DOCTOR_CHANNEL_CAPABILITIES: Readonly> = { + matrix: { + dmAllowFromMode: "nestedOnly", + groupModel: "sender", + groupAllowFromFallbackToAllowFrom: false, + warnOnEmptyGroupSenderAllowlist: true, + }, + msteams: { + dmAllowFromMode: "topOnly", + groupModel: "hybrid", + groupAllowFromFallbackToAllowFrom: false, + warnOnEmptyGroupSenderAllowlist: true, + }, + zalouser: { + dmAllowFromMode: "topOnly", + groupModel: "hybrid", + groupAllowFromFallbackToAllowFrom: false, + warnOnEmptyGroupSenderAllowlist: false, + }, +}; + export function getDoctorChannelCapabilities(channelName?: string): DoctorChannelCapabilities { if (!channelName) { return DEFAULT_DOCTOR_CHANNEL_CAPABILITIES; } + const staticCapabilities = STATIC_DOCTOR_CHANNEL_CAPABILITIES[channelName]; + if (staticCapabilities) { + return staticCapabilities; + } + const registeredChannelId = normalizeAnyChannelId(channelName); + if (!registeredChannelId) { + return DEFAULT_DOCTOR_CHANNEL_CAPABILITIES; + } const pluginDoctor = - getChannelPlugin(channelName)?.doctor ?? getBundledChannelPlugin(channelName)?.doctor; + getChannelPlugin(registeredChannelId)?.doctor ?? + getBundledChannelPlugin(registeredChannelId)?.doctor; if (pluginDoctor) { return { dmAllowFromMode: