惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

U
Unit 42
Vercel News
Vercel News
博客园 - 叶小钗
大猫的无限游戏
大猫的无限游戏
MyScale Blog
MyScale Blog
P
Proofpoint News Feed
量子位
Engineering at Meta
Engineering at Meta
B
Blog RSS Feed
博客园 - 【当耐特】
Recent Announcements
Recent Announcements
Google DeepMind News
Google DeepMind News
D
DataBreaches.Net
Stack Overflow Blog
Stack Overflow Blog
博客园 - 聂微东
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
人人都是产品经理
人人都是产品经理
IT之家
IT之家
T
The Blog of Author Tim Ferriss
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Jina AI
Jina AI
博客园 - 三生石上(FineUI控件)

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(slack): bound subteam member cache clocks · openclaw/...
steipete · 2026-05-30 · via Recent Commits to openclaw:main

File tree

  • extensions/slack/src/monitor/message-handler

Original file line numberDiff line numberDiff line change

@@ -71,6 +71,52 @@ describe("Slack subteam mentions", () => {

7171

expect(client.usergroups.users.list).toHaveBeenCalledTimes(1);

7272

});

7373
74+

it("drops cached membership lookups when the current clock is not a valid date timestamp", async () => {

75+

const client = createClient(["U_BOT"]);

76+
77+

await expect(

78+

isSlackSubteamMentionForBot({

79+

client,

80+

text: "<!subteam^S123> ping",

81+

botUserId: "U_BOT",

82+

now: 1_700_000_000_000,

83+

}),

84+

).resolves.toBe(true);

85+

await expect(

86+

isSlackSubteamMentionForBot({

87+

client,

88+

text: "<!subteam^S123> ping again",

89+

botUserId: "U_BOT",

90+

now: Number.NaN,

91+

}),

92+

).resolves.toBe(true);

93+
94+

expect(client.usergroups.users.list).toHaveBeenCalledTimes(2);

95+

});

96+
97+

it("does not cache membership lookups when the expiry timestamp would exceed the valid date range", async () => {

98+

const client = createClient(["U_BOT"]);

99+
100+

await expect(

101+

isSlackSubteamMentionForBot({

102+

client,

103+

text: "<!subteam^S123> ping",

104+

botUserId: "U_BOT",

105+

now: 8_640_000_000_000_000,

106+

}),

107+

).resolves.toBe(true);

108+

await expect(

109+

isSlackSubteamMentionForBot({

110+

client,

111+

text: "<!subteam^S123> ping again",

112+

botUserId: "U_BOT",

113+

now: 1_700_000_000_000,

114+

}),

115+

).resolves.toBe(true);

116+
117+

expect(client.usergroups.users.list).toHaveBeenCalledTimes(2);

118+

});

119+
74120

it("fails closed when Slack rejects the user-group lookup", async () => {

75121

const log = vi.fn();

76122

const client = createClient([]);

Original file line numberDiff line numberDiff line change

@@ -1,5 +1,9 @@

11

import type { WebClient } from "@slack/web-api";

22

import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";

3+

import {

4+

asDateTimestampMs,

5+

resolveExpiresAtMsFromDurationMs,

6+

} from "openclaw/plugin-sdk/number-runtime";

37

import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";

48
59

const SUBTEAM_MENTION_RE = /<!subteam\^([A-Z0-9]+)(?:\|[^>]*)?>/gi;

@@ -44,8 +48,16 @@ async function readSlackSubteamUsers(params: {

4448

}

4549

const cacheKey = `${normalizeSlackId(params.teamId) ?? ""}:${params.subteamId}`;

4650

const cached = bySubteam.get(cacheKey);

47-

if (cached && cached.expiresAt > params.now) {

48-

return cached.users;

51+

const now = asDateTimestampMs(params.now);

52+

if (cached) {

53+

if (

54+

now !== undefined &&

55+

asDateTimestampMs(cached.expiresAt) !== undefined &&

56+

cached.expiresAt > now

57+

) {

58+

return cached.users;

59+

}

60+

bySubteam.delete(cacheKey);

4961

}

5062
5163

try {

@@ -62,10 +74,15 @@ async function readSlackSubteamUsers(params: {

6274

const users = new Set(

6375

(response.users ?? []).map((userId) => normalizeSlackId(userId)).filter(Boolean) as string[],

6476

);

65-

bySubteam.set(cacheKey, {

66-

expiresAt: params.now + SUBTEAM_MEMBER_CACHE_TTL_MS,

67-

users,

77+

const expiresAt = resolveExpiresAtMsFromDurationMs(SUBTEAM_MEMBER_CACHE_TTL_MS, {

78+

nowMs: params.now,

6879

});

80+

if (expiresAt !== undefined) {

81+

bySubteam.set(cacheKey, {

82+

expiresAt,

83+

users,

84+

});

85+

}

6986

return users;

7087

} catch (err) {

7188

params.log?.(