From 95093303c871e5ee45ca1ce4e1c6b4630643244f Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Mon, 22 Jun 2026 16:53:11 +0800 Subject: [PATCH] chore(deadcode): remove test-only channel helpers --- extensions/irc/src/normalize.test.ts | 20 ------------------ extensions/irc/src/normalize.ts | 21 ------------------- ...to-reply.web-auto-reply.last-route.test.ts | 7 ++++--- .../src/auto-reply/monitor/last-route.ts | 9 -------- 4 files changed, 4 insertions(+), 53 deletions(-) diff --git a/extensions/irc/src/normalize.test.ts b/extensions/irc/src/normalize.test.ts index c437fe7b4e21..51b4763244f5 100644 --- a/extensions/irc/src/normalize.test.ts +++ b/extensions/irc/src/normalize.test.ts @@ -4,7 +4,6 @@ import { buildIrcAllowlistCandidates, normalizeIrcAllowEntry, normalizeIrcMessagingTarget, - resolveIrcAllowlistMatch, } from "./normalize.js"; describe("irc normalize", () => { @@ -33,24 +32,5 @@ describe("irc normalize", () => { expect(buildIrcAllowlistCandidates(message)).toContain("alice!ident@example.org"); expect(buildIrcAllowlistCandidates(message)).not.toContain("alice"); expect(buildIrcAllowlistCandidates(message, { allowNameMatching: true })).toContain("alice"); - expect( - resolveIrcAllowlistMatch({ - allowFrom: ["alice!ident@example.org"], - message, - }).allowed, - ).toBe(true); - expect( - resolveIrcAllowlistMatch({ - allowFrom: ["alice"], - message, - }).allowed, - ).toBe(false); - expect( - resolveIrcAllowlistMatch({ - allowFrom: ["alice"], - message, - allowNameMatching: true, - }).allowed, - ).toBe(true); }); }); diff --git a/extensions/irc/src/normalize.ts b/extensions/irc/src/normalize.ts index f20c8bdd6946..600e185f8b1f 100644 --- a/extensions/irc/src/normalize.ts +++ b/extensions/irc/src/normalize.ts @@ -2,7 +2,6 @@ import { normalizeLowercaseStringOrEmpty, normalizeOptionalLowercaseString, - normalizeStringEntriesLower, } from "openclaw/plugin-sdk/string-coerce-runtime"; import { hasIrcControlChars } from "./control-chars.js"; import type { IrcInboundMessage } from "./types.js"; @@ -85,23 +84,3 @@ export function buildIrcAllowlistCandidates( } return [...candidates]; } - -export function resolveIrcAllowlistMatch(params: { - allowFrom: string[]; - message: IrcInboundMessage; - allowNameMatching?: boolean; -}): { allowed: boolean; source?: string } { - const allowFrom = new Set(normalizeStringEntriesLower(params.allowFrom)); - if (allowFrom.has("*")) { - return { allowed: true, source: "wildcard" }; - } - const candidates = buildIrcAllowlistCandidates(params.message, { - allowNameMatching: params.allowNameMatching, - }); - for (const candidate of candidates) { - if (allowFrom.has(candidate)) { - return { allowed: true, source: candidate }; - } - } - return { allowed: false }; -} diff --git a/extensions/whatsapp/src/auto-reply.web-auto-reply.last-route.test.ts b/extensions/whatsapp/src/auto-reply.web-auto-reply.last-route.test.ts index 460f4b5fb1f0..5561496d38bf 100644 --- a/extensions/whatsapp/src/auto-reply.web-auto-reply.last-route.test.ts +++ b/extensions/whatsapp/src/auto-reply.web-auto-reply.last-route.test.ts @@ -5,7 +5,6 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; import { installWebAutoReplyUnitTestHooks, makeSessionStore } from "./auto-reply.test-harness.js"; import { buildMentionConfig } from "./auto-reply/mentions.js"; import { createEchoTracker } from "./auto-reply/monitor/echo.js"; -import { awaitBackgroundTasks } from "./auto-reply/monitor/last-route.js"; import { createWebOnMessageHandler } from "./auto-reply/monitor/on-message.js"; import { createTestWebInboundMessage } from "./inbound/test-message.test-helper.js"; @@ -134,7 +133,8 @@ describe("web auto-reply last-route", () => { }), ); - await awaitBackgroundTasks(backgroundTasks); + await Promise.allSettled(backgroundTasks); + backgroundTasks.clear(); expect(updateLastRouteInBackgroundMock).toHaveBeenCalledTimes(1); const updateParams = updateLastRouteInBackgroundMock.mock.calls.at(0)?.[0] as @@ -211,7 +211,8 @@ describe("web auto-reply last-route", () => { }), ); - await awaitBackgroundTasks(backgroundTasks); + await Promise.allSettled(backgroundTasks); + backgroundTasks.clear(); expect(updateLastRouteInBackgroundMock).toHaveBeenCalledTimes(1); const updateParams = updateLastRouteInBackgroundMock.mock.calls.at(0)?.[0] as diff --git a/extensions/whatsapp/src/auto-reply/monitor/last-route.ts b/extensions/whatsapp/src/auto-reply/monitor/last-route.ts index 2346fbffda7d..e0d944a44d98 100644 --- a/extensions/whatsapp/src/auto-reply/monitor/last-route.ts +++ b/extensions/whatsapp/src/auto-reply/monitor/last-route.ts @@ -51,12 +51,3 @@ export function updateLastRouteInBackground(params: { }); trackBackgroundTask(params.backgroundTasks, task); } - -export function awaitBackgroundTasks(backgroundTasks: Set>) { - if (backgroundTasks.size === 0) { - return Promise.resolve(); - } - return Promise.allSettled(backgroundTasks).then(() => { - backgroundTasks.clear(); - }); -}