Skip to content

Commit 31adcb8

Browse files
committed
msteams: preserve sent-message marker TTL on recovery
1 parent 351c086 commit 31adcb8

3 files changed

Lines changed: 42 additions & 10 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ Docs: https://docs.openclaw.ai
424424
- Slack: publish a safe default App Home tab view on `app_home_opened` and include the Home tab event in setup manifests. Fixes #11655; refs #52020. Thanks @TinyTb.
425425
- Slack: keep track of bot-participated threads across restarts, so ongoing threaded conversations can continue auto-replying after the Gateway is restarted. Thanks @amknight.
426426
- Control UI/Usage: add UTC quarter-hour token buckets for the Usage Mosaic and reuse them for hour filtering, keeping the legacy session-span fallback for older summaries. (#74337) Thanks @konanok.
427-
- Microsoft Teams: keep reply context for recent bot messages across Gateway restarts, so follow-up replies continue to be handled correctly after updates or restarts. Thanks @amknight.
427+
- Microsoft Teams: keep follow-up replies to recent bot messages working after Gateway updates or restarts, so conversations do not lose track of which bot message a user is answering. Thanks @amknight.
428428
- BlueBubbles: add opt-in `channels.bluebubbles.replyContextApiFallback` that fetches the original message from the BlueBubbles HTTP API when the in-memory reply-context cache misses (multi-instance deployments sharing one BB account, post-restart, after long-lived TTL/LRU eviction). Off by default; channel-level setting propagates to accounts that omit the flag through `mergeAccountConfig`; routed through the typed `BlueBubblesClient` so every fetch is SSRF-guarded by the same three-mode policy as every other BB client request; reply-id shape is validated and part-index prefixes (`p:0/<guid>`) are stripped before the request; concurrent webhooks for the same `replyToId` coalesce into one fetch and successful responses populate the reply cache for subsequent hits. Also promotes BlueBubbles attachment download failures from verbose to runtime error so silently-dropped inbound images are visible at default log level, and extends `sanitizeForLog` to redact `?password=…`/`?token=…` query params and `Authorization:` headers before they reach the log sink (CWE-532). (#71820) Thanks @coletebou and @zqchris.
429429
- CLI/proxy: add `openclaw proxy validate` so operators can verify effective proxy configuration, proxy reachability, and expected allow/deny destination behavior before deploying proxy-routed OpenClaw commands. (#73438) Thanks @jesse-merhi.
430430
- Agents/Codex: default Codex app-server dynamic tools to native-first, keeping OpenClaw integration tools while leaving file, patch, exec, and process ownership to the Codex harness. (#75308) Thanks @pashpashpash.

‎extensions/msteams/src/sent-message-cache.test.ts‎

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import {
77
wasMSTeamsMessageSentWithPersistence,
88
} from "./sent-message-cache.js";
99

10+
const TTL_MS = 24 * 60 * 60 * 1000;
11+
1012
describe("msteams sent message cache", () => {
1113
afterEach(() => {
1214
clearMSTeamsSentMessageCache();
@@ -21,7 +23,7 @@ describe("msteams sent message cache", () => {
2123

2224
it("persists sent message ids when runtime state is available", async () => {
2325
const register = vi.fn().mockResolvedValue(undefined);
24-
const lookup = vi.fn().mockResolvedValue({ sentAt: 123 });
26+
const lookup = vi.fn().mockResolvedValue({ sentAt: Date.now() });
2527
const openKeyedStore = vi.fn(() => ({
2628
register,
2729
lookup,
@@ -55,6 +57,35 @@ describe("msteams sent message cache", () => {
5557
expect(lookup).not.toHaveBeenCalled();
5658
});
5759

60+
it("preserves the original TTL when recovering sent-message ids from persistent state", async () => {
61+
const sentAt = 1_000_000;
62+
const lookup = vi.fn().mockResolvedValue({ sentAt });
63+
const openKeyedStore = vi.fn(() => ({
64+
register: vi.fn(),
65+
lookup,
66+
consume: vi.fn(),
67+
delete: vi.fn(),
68+
entries: vi.fn(),
69+
clear: vi.fn(),
70+
}));
71+
setMSTeamsRuntime({
72+
state: { openKeyedStore },
73+
logging: { getChildLogger: () => ({ warn: vi.fn() }) },
74+
} as never);
75+
76+
vi.spyOn(Date, "now").mockReturnValue(sentAt + TTL_MS - 1);
77+
await expect(
78+
wasMSTeamsMessageSentWithPersistence({ conversationId: "conv-1", messageId: "msg-4" }),
79+
).resolves.toBe(true);
80+
expect(wasMSTeamsMessageSent("conv-1", "msg-4")).toBe(true);
81+
82+
lookup.mockClear();
83+
vi.mocked(Date.now).mockReturnValue(sentAt + TTL_MS + 1);
84+
85+
expect(wasMSTeamsMessageSent("conv-1", "msg-4")).toBe(false);
86+
expect(lookup).not.toHaveBeenCalled();
87+
});
88+
5889
it("falls back to in-memory sent-message markers when persistent state cannot open", () => {
5990
const warn = vi.fn();
6091
setMSTeamsRuntime({

‎extensions/msteams/src/sent-message-cache.ts‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,16 @@ function rememberPersistentSentMessage(params: {
118118
async function lookupPersistentSentMessage(params: {
119119
conversationId: string;
120120
messageId: string;
121-
}): Promise<boolean> {
121+
}): Promise<number | undefined> {
122122
const store = getPersistentSentMessageStore();
123123
if (!store) {
124-
return false;
124+
return undefined;
125125
}
126126
try {
127-
return Boolean(await store.lookup(makePersistentKey(params.conversationId, params.messageId)));
127+
return (await store.lookup(makePersistentKey(params.conversationId, params.messageId)))?.sentAt;
128128
} catch (error) {
129129
disablePersistentSentMessageStore(error);
130-
return false;
130+
return undefined;
131131
}
132132
}
133133

@@ -159,11 +159,12 @@ export async function wasMSTeamsMessageSentWithPersistence(params: {
159159
if (wasMSTeamsMessageSent(params.conversationId, params.messageId)) {
160160
return true;
161161
}
162-
const found = await lookupPersistentSentMessage(params);
163-
if (found) {
164-
rememberSentMessageInMemory(params.conversationId, params.messageId, Date.now());
162+
const sentAt = await lookupPersistentSentMessage(params);
163+
if (sentAt == null) {
164+
return false;
165165
}
166-
return found;
166+
rememberSentMessageInMemory(params.conversationId, params.messageId, sentAt);
167+
return wasMSTeamsMessageSent(params.conversationId, params.messageId);
167168
}
168169

169170
export function clearMSTeamsSentMessageCache(): void {

0 commit comments

Comments
 (0)