Skip to content

Commit 0fac83f

Browse files
author
Homer
committed
fix(imessage): bound HEIC staging conversion
1 parent dc81190 commit 0fac83f

3 files changed

Lines changed: 26 additions & 26 deletions

File tree

extensions/imessage/src/monitor/media-staging.ts

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import type { IMessageAttachment } from "./types.js";
99

1010
const execFileAsync = promisify(execFile);
1111

12+
const HEIC_CONVERSION_TIMEOUT_MS = 15_000;
13+
const HEIC_CONVERSION_MAX_BUFFER_BYTES = 64 * 1024;
14+
1215
export type StagedIMessageAttachment = {
1316
path: string;
1417
contentType?: string;
@@ -76,19 +79,27 @@ async function convertHeicToJpegWithSips(sourcePath: string, maxBytes: number):
7679
extension: "jpg",
7780
});
7881
try {
79-
await execFileAsync("sips", [
80-
"-s",
81-
"format",
82-
"jpeg",
83-
"-s",
84-
"formatOptions",
85-
"90",
86-
"-Z",
87-
"4096",
88-
sourcePath,
89-
"--out",
90-
tempPath,
91-
]);
82+
await execFileAsync(
83+
"sips",
84+
[
85+
"-s",
86+
"format",
87+
"jpeg",
88+
"-s",
89+
"formatOptions",
90+
"90",
91+
"-Z",
92+
"4096",
93+
sourcePath,
94+
"--out",
95+
tempPath,
96+
],
97+
{
98+
timeout: HEIC_CONVERSION_TIMEOUT_MS,
99+
maxBuffer: HEIC_CONVERSION_MAX_BUFFER_BYTES,
100+
killSignal: "SIGKILL",
101+
},
102+
);
92103
const stat = await fs.stat(tempPath);
93104
if (stat.size > maxBytes) {
94105
throw new Error(`converted media exceeds ${Math.round(maxBytes / (1024 * 1024))}MB limit`);

src/cron/delivery.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ describe("resolveCronDeliveryPlan", () => {
170170
}
171171
});
172172

173-
it("does not treat channel-owned service prefixes as provider selection", () => {
173+
it("uses iMessage target prefixes as provider selection", () => {
174174
setCronDeliveryTestRegistry([
175175
{
176176
pluginId: "imessage",
@@ -189,7 +189,7 @@ describe("resolveCronDeliveryPlan", () => {
189189
}),
190190
);
191191
expect(plan.mode).toBe("announce");
192-
expect(plan.channel).toBe("last");
192+
expect(plan.channel).toBe("imessage");
193193
expect(plan.to).toBe("imessage:+15551234567");
194194
});
195195
});

src/infra/outbound/channel-target-prefix.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,11 @@ import { normalizeOptionalLowercaseString } from "../../shared/string-coerce.js"
33
import { normalizeMessageChannel } from "../../utils/message-channel-core.js";
44

55
const TARGET_KIND_PREFIXES = new Set([
6-
"auto",
76
"channel",
8-
"chat",
9-
"chat_guid",
10-
"chat_identifier",
11-
"chat_id",
12-
"chatguid",
13-
"chatid",
14-
"chatident",
157
"conversation",
168
"dm",
179
"group",
18-
"guid",
19-
"imessage",
2010
"room",
21-
"sms",
2211
"thread",
2312
"user",
2413
]);

0 commit comments

Comments
 (0)