mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-25 11:55:47 -06:00
chore(deadcode): remove test-only channel helpers
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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 };
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -51,12 +51,3 @@ export function updateLastRouteInBackground(params: {
|
||||
});
|
||||
trackBackgroundTask(params.backgroundTasks, task);
|
||||
}
|
||||
|
||||
export function awaitBackgroundTasks(backgroundTasks: Set<Promise<unknown>>) {
|
||||
if (backgroundTasks.size === 0) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
return Promise.allSettled(backgroundTasks).then(() => {
|
||||
backgroundTasks.clear();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user