

























@@ -70,6 +70,64 @@ describe("resolveTelegramInboundBody", () => {
7070});
7171});
727273+it("uses saved media MIME for no-caption photo placeholders", async () => {
74+const result = await resolveTelegramBody({
75+msg: {
76+message_id: 3,
77+date: 1_700_000_003,
78+chat: { id: 42, type: "private", first_name: "Pat" },
79+from: { id: 42, first_name: "Pat" },
80+photo: [{ file_id: "photo-1", file_unique_id: "photo-u1", width: 120, height: 80 }],
81+} as never,
82+allMedia: [{ path: "/tmp/upload.bin", contentType: "application/octet-stream" }],
83+});
84+85+expect(result).toMatchObject({
86+rawBody: "<media:image>",
87+bodyText: "<media:document>",
88+});
89+});
90+91+it("summarizes multiple saved images as images", async () => {
92+const result = await resolveTelegramBody({
93+msg: {
94+message_id: 4,
95+date: 1_700_000_004,
96+chat: { id: 42, type: "private", first_name: "Pat" },
97+from: { id: 42, first_name: "Pat" },
98+photo: [{ file_id: "photo-2", file_unique_id: "photo-u2", width: 120, height: 80 }],
99+} as never,
100+allMedia: [
101+{ path: "/tmp/photo-1.webp", contentType: "image/webp" },
102+{ path: "/tmp/photo-2.png", contentType: "image/png" },
103+],
104+});
105+106+expect(result).toMatchObject({
107+bodyText: "<media:image> (2 images)",
108+});
109+});
110+111+it("summarizes mixed saved media as attachments", async () => {
112+const result = await resolveTelegramBody({
113+msg: {
114+message_id: 5,
115+date: 1_700_000_005,
116+chat: { id: 42, type: "private", first_name: "Pat" },
117+from: { id: 42, first_name: "Pat" },
118+photo: [{ file_id: "photo-3", file_unique_id: "photo-u3", width: 120, height: 80 }],
119+} as never,
120+allMedia: [
121+{ path: "/tmp/photo.webp", contentType: "image/webp" },
122+{ path: "/tmp/report.pdf", contentType: "application/pdf" },
123+],
124+});
125+126+expect(result).toMatchObject({
127+bodyText: "<media:document> (2 attachments)",
128+});
129+});
130+73131it("does not transcribe group audio for unauthorized senders", async () => {
74132transcribeFirstAudioMock.mockReset();
75133const logger = { info: vi.fn() };
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。