refactor(channels): dedupe transport and gateway test scaffolds

This commit is contained in:
Peter Steinberger
2026-02-16 14:52:15 +00:00
parent f717a13039
commit 93ca0ed54f
95 changed files with 4068 additions and 5221 deletions

View File

@@ -1,6 +1,7 @@
import type { WebClient as SlackWebClient } from "@slack/web-api";
import type { SlackMessageEvent } from "../types.js";
import { logVerbose, shouldLogVerbose } from "../../globals.js";
import { pruneMapToMaxSize } from "../../infra/map-size.js";
type ThreadTsCacheEntry = {
threadTs: string | null;
@@ -68,17 +69,7 @@ export function createSlackThreadTsResolver(params: {
const setCached = (key: string, threadTs: string | null, now: number) => {
cache.delete(key);
cache.set(key, { threadTs, updatedAt: now });
if (maxSize <= 0) {
cache.clear();
return;
}
while (cache.size > maxSize) {
const oldestKey = cache.keys().next().value;
if (!oldestKey) {
break;
}
cache.delete(oldestKey);
}
pruneMapToMaxSize(cache, maxSize);
};
return {