



























@@ -10,7 +10,11 @@ import {
1010resolveConfiguredBindingRoute,
1111resolveRuntimeConversationBindingRoute,
1212} from "openclaw/plugin-sdk/conversation-runtime";
13-import { parseStrictNonNegativeInteger } from "openclaw/plugin-sdk/number-runtime";
13+import {
14+asDateTimestampMs,
15+parseStrictNonNegativeInteger,
16+resolveExpiresAtMsFromDurationMs,
17+} from "openclaw/plugin-sdk/number-runtime";
1418import {
1519DEFAULT_GROUP_HISTORY_LIMIT,
1620createChannelHistoryWindow,
@@ -108,9 +112,14 @@ function isFeishuTopicSessionScope(scope: FeishuGroupSessionScope): boolean {
108112}
109113110114function evictGroupNameCache(): void {
111-const now = Date.now();
115+const now = asDateTimestampMs(Date.now());
116+if (now === undefined) {
117+groupNameCache.clear();
118+return;
119+}
112120for (const [key, val] of groupNameCache) {
113-if (val.expiresAt <= now) {
121+const expiresAt = asDateTimestampMs(val.expiresAt);
122+if (expiresAt === undefined || expiresAt <= now) {
114123groupNameCache.delete(key);
115124}
116125}
@@ -128,9 +137,12 @@ function evictGroupNameCache(): void {
128137}
129138}
130139131-function setCacheEntry(key: string, value: { name: string; expiresAt: number }): void {
140+function setCacheEntry(key: string, name: string): void {
141+const expiresAt = resolveExpiresAtMsFromDurationMs(GROUP_NAME_CACHE_TTL_MS);
132142groupNameCache.delete(key);
133-groupNameCache.set(key, value);
143+if (expiresAt !== undefined) {
144+groupNameCache.set(key, { name, expiresAt });
145+}
134146}
135147136148export function clearGroupNameCache(): void {
@@ -150,37 +162,34 @@ export async function resolveGroupName(params: {
150162const cacheKey = `${account.accountId}:${chatId}`;
151163152164const cached = groupNameCache.get(cacheKey);
153-if (cached && cached.expiresAt > Date.now()) {
154-return cached.name || undefined;
165+if (cached) {
166+const now = asDateTimestampMs(Date.now());
167+const expiresAt = asDateTimestampMs(cached.expiresAt);
168+if (now !== undefined && expiresAt !== undefined && expiresAt > now) {
169+return cached.name || undefined;
170+}
171+groupNameCache.delete(cacheKey);
155172}
156173174+let resolvedName: string | undefined;
157175try {
158176const client = createFeishuClient(account);
159177const chatInfo = await getChatInfo(client, chatId);
160178const name = chatInfo?.name?.trim();
161179if (name) {
162-setCacheEntry(cacheKey, {
163- name,
164-expiresAt: Date.now() + GROUP_NAME_CACHE_TTL_MS,
165-});
180+setCacheEntry(cacheKey, name);
181+resolvedName = name;
166182} else {
167-setCacheEntry(cacheKey, {
168-name: "",
169-expiresAt: Date.now() + GROUP_NAME_CACHE_TTL_MS,
170-});
183+setCacheEntry(cacheKey, "");
171184}
172185} catch (err) {
173186log(`feishu[${account.accountId}]: getChatInfo failed for ${chatId}: ${String(err)}`);
174-setCacheEntry(cacheKey, {
175-name: "",
176-expiresAt: Date.now() + GROUP_NAME_CACHE_TTL_MS,
177-});
187+setCacheEntry(cacheKey, "");
178188}
179189180-const result = groupNameCache.get(cacheKey)?.name || undefined;
181190evictGroupNameCache();
182191183-return result;
192+return resolvedName;
184193}
185194186195async function resolveFeishuAudioPreflightTranscript(params: {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。