mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 20:48:26 +00:00
refactor(channels): dedupe transport and gateway test scaffolds
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user