mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-14 18:51:04 +00:00
perf: short-circuit static doctor channel capabilities
This commit is contained in:
@@ -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<Record<string, DoctorChannelCapabilities>> = {
|
||||
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:
|
||||
|
||||
Reference in New Issue
Block a user