refactor: prune unused extension helpers

This commit is contained in:
Peter Steinberger
2026-05-01 09:24:37 +01:00
parent 465d1b0d4b
commit 6efb44944c
7 changed files with 2 additions and 88 deletions

View File

@@ -92,9 +92,3 @@ export function resolveBlueBubblesEffectiveAllowPrivateNetwork(params: {
}): boolean {
return resolveBlueBubblesEffectiveAllowPrivateNetworkFromConfig(params);
}
export function listEnabledBlueBubblesAccounts(cfg: OpenClawConfig): ResolvedBlueBubblesAccount[] {
return listBlueBubblesAccountIds(cfg)
.map((accountId) => resolveBlueBubblesAccount({ cfg, accountId }))
.filter((account) => account.enabled);
}

View File

@@ -133,11 +133,6 @@ export function isMacOS26OrHigher(accountId?: string): boolean {
return major !== null && major >= 26;
}
/** Clear the server info cache (for testing) */
export function clearServerInfoCache(): void {
serverInfoCache.clear();
}
export async function probeBlueBubbles(params: {
baseUrl?: string | null;
password?: string | null;

View File

@@ -12,10 +12,6 @@ export function clearBlueBubblesRuntime(): void {
runtimeStore.clearRuntime();
}
export function tryGetBlueBubblesRuntime(): PluginRuntime | null {
return runtimeStore.tryGetRuntime();
}
export function getBlueBubblesRuntime(): PluginRuntime {
return runtimeStore.getRuntime();
}

View File

@@ -173,19 +173,6 @@ export function normalizeBlueBubblesServerUrl(raw: string): string {
return withScheme.replace(/\/+$/, "");
}
export function buildBlueBubblesApiUrl(params: {
baseUrl: string;
path: string;
password?: string;
}): string {
const normalized = normalizeBlueBubblesServerUrl(params.baseUrl);
const url = new URL(params.path, `${normalized}/`);
if (params.password) {
url.searchParams.set("password", params.password);
}
return url.toString();
}
// Overridable guard for testing; production code uses fetchWithSsrFGuard.
let _fetchGuard = fetchWithSsrFGuard;

View File

@@ -32,14 +32,6 @@ export function extractDiscordChannelId(sessionKey?: string | null): string | nu
return match ? match[1] : null;
}
export function extractDiscordThreadId(sessionKey?: string | null): string | null {
if (!sessionKey) {
return null;
}
const match = sessionKey.match(/discord:(?:channel|group):\d+:thread:(\d+)/);
return match ? match[1] : null;
}
function extractDiscordSessionKind(sessionKey?: string | null): "channel" | "group" | "dm" | null {
if (!sessionKey) {
return null;
@@ -220,16 +212,8 @@ export function createDiscordNativeApprovalAdapter(
}
let cachedDiscordApprovalCapability: ReturnType<typeof createDiscordApprovalCapability> | undefined;
let cachedDiscordNativeApprovalAdapter:
| ReturnType<typeof createDiscordNativeApprovalAdapter>
| undefined;
export function getDiscordApprovalCapability() {
cachedDiscordApprovalCapability ??= createDiscordApprovalCapability();
return cachedDiscordApprovalCapability;
}
export function getDiscordNativeApprovalAdapter() {
cachedDiscordNativeApprovalAdapter ??= createDiscordNativeApprovalAdapter();
return cachedDiscordNativeApprovalAdapter;
}

View File

@@ -1,30 +1,12 @@
/**
* Media type detection — pure functions for classifying files by MIME or extension.
*
* These replace the inline `isImageFile`, `isVideoFile`, `isAudioFile` helpers
* scattered across `outbound.ts`. Centralizing them here ensures consistent
* detection across both the built-in and standalone versions.
* These replace the inline `isImageFile` and `isVideoFile` helpers scattered
* across `outbound.ts`. Centralizing them here keeps detection consistent.
*/
/** Supported media kind for QQ Bot outbound routing. */
export type MediaKind = "image" | "voice" | "video" | "file";
const IMAGE_EXTENSIONS = new Set([".jpg", ".jpeg", ".png", ".gif", ".webp", ".bmp"]);
const VIDEO_EXTENSIONS = new Set([".mp4", ".mov", ".avi", ".mkv", ".webm", ".flv", ".wmv"]);
const AUDIO_EXTENSIONS = new Set([
".mp3",
".wav",
".ogg",
".flac",
".aac",
".m4a",
".wma",
".opus",
".amr",
".silk",
".slk",
".pcm",
]);
/**
* Extract a lowercase file extension from a path or URL, ignoring query and hash.
@@ -53,18 +35,3 @@ export function isVideoFile(filePath: string, mimeType?: string): boolean {
}
return VIDEO_EXTENSIONS.has(getCleanExtension(filePath));
}
/** Check whether a file is audio using MIME first and extension as fallback. */
export function isAudioFile(filePath: string, mimeType?: string): boolean {
if (mimeType) {
if (
mimeType.startsWith("audio/") ||
mimeType === "voice" ||
mimeType.includes("silk") ||
mimeType.includes("amr")
) {
return true;
}
}
return AUDIO_EXTENSIONS.has(getCleanExtension(filePath));
}

View File

@@ -385,12 +385,3 @@ export function isSummarizationRequest(messageText: string): boolean {
];
return patterns.some((pattern) => pattern.test(messageText));
}
export function formatChangesDate(daysAgo = 5): string {
const now = new Date();
const targetDate = new Date(now.getTime() - daysAgo * 24 * 60 * 60 * 1000);
const year = targetDate.getFullYear();
const month = targetDate.getMonth() + 1;
const day = targetDate.getDate();
return `~${year}.${month}.${day}..20.19.51..9b9d`;
}