
























@@ -2,6 +2,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
22import type { BlueBubblesClient, createBlueBubblesClientFromParts } from "./client.js";
33import {
44_resetBlueBubblesShortIdState,
5+getShortIdForUuid,
56resolveReplyContextFromCache,
67} from "./monitor-reply-cache.js";
78import {
@@ -138,6 +139,53 @@ describe("fetchBlueBubblesReplyContext", () => {
138139expect(requestCalls[0]?.path).toBe("/api/v1/message/msg-bare-guid");
139140});
140141142+it("populates the reply cache for the original prefixed reply id", async () => {
143+const { factory } = makeFakeClient([
144+jsonResponse({ data: { text: "cached prefix", handle: { address: "+15551112222" } } }),
145+]);
146+await fetchBlueBubblesReplyContext({
147+ ...baseParams,
148+replyToId: "p:0/msg-prefixed-cache",
149+chatGuid: "iMessage;-;+15551112222",
150+clientFactory: factory,
151+});
152+const cached = resolveReplyContextFromCache({
153+accountId: "default",
154+replyToId: "p:0/msg-prefixed-cache",
155+chatGuid: "iMessage;-;+15551112222",
156+});
157+expect(cached?.body).toBe("cached prefix");
158+expect(cached?.senderLabel).toBe("+15551112222");
159+});
160+161+it("does not cache non-part-index slash prefixes as aliases", async () => {
162+const { factory, requestCalls } = makeFakeClient([
163+jsonResponse({ data: { text: "cached bare only", handle: { address: "+15551112222" } } }),
164+]);
165+await fetchBlueBubblesReplyContext({
166+ ...baseParams,
167+replyToId: "../etc/passwd",
168+chatGuid: "iMessage;-;+15551112222",
169+clientFactory: factory,
170+});
171+expect(requestCalls[0]?.path).toBe("/api/v1/message/passwd");
172+expect(
173+resolveReplyContextFromCache({
174+accountId: "default",
175+replyToId: "passwd",
176+chatGuid: "iMessage;-;+15551112222",
177+})?.body,
178+).toBe("cached bare only");
179+expect(
180+resolveReplyContextFromCache({
181+accountId: "default",
182+replyToId: "../etc/passwd",
183+chatGuid: "iMessage;-;+15551112222",
184+}),
185+).toBeNull();
186+expect(getShortIdForUuid("../etc/passwd")).toBeUndefined();
187+});
188+141189it("fetches the BB API and returns body + normalized sender on success", async () => {
142190const { factory, requestCalls } = makeFakeClient([
143191jsonResponse({
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。