Gateway: review fixes for stale summaries, history cursors that survive a moving window, timeouts on T3 calls, push size, T3's snooze rules, and input checks
This commit is contained in:
1 parent
edc4b88990
commit
99b300855e
13 files changed
+208
-58
No files matched your search
@@ -2,7 +2,7 @@ import { describe, expect, it } from "bun:test";
|
||||
|
||||
import type { DeviceRow } from "../src/db.ts";
|
||||
import type { Push } from "../src/notify.ts";
|
||||
import { notificationPrefs, wants } from "../src/push.ts";
|
||||
import { apnsPayload, notificationPrefs, wants } from "../src/push.ts";
|
||||
|
||||
const push = (category: Push["category"], fromSubagent = false): Push => ({
|
||||
title: "Receipt OCR",
|
||||
@@ -35,3 +35,23 @@ describe("wants", () => {
|
||||
expect(wants({ needsMe: false, finished: false, failed: false, subagents: false }, push("host"))).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("apnsPayload", () => {
|
||||
it("drops the question's buttons, then cuts the body, to stay under APNs' 4 KB", () => {
|
||||
const wide = "界".repeat(400);
|
||||
const big: Push = {
|
||||
...push("input"),
|
||||
title: "界".repeat(80),
|
||||
body: wide,
|
||||
data: {
|
||||
hostId: "host-1",
|
||||
threadId: "thread-1",
|
||||
question: { id: "q", options: [1, 2, 3, 4].map((n) => ({ label: `${n}${"界".repeat(39)}`, value: "界".repeat(200) })), allowCustomAnswer: true },
|
||||
},
|
||||
};
|
||||
const payload = apnsPayload(big);
|
||||
expect(Buffer.byteLength(JSON.stringify(payload))).toBeLessThanOrEqual(3900);
|
||||
expect("question" in payload).toBe(false);
|
||||
expect(apnsPayload(push("finished"))).toMatchObject({ aps: { alert: { body: "Finished." } }, threadId: "thread-1" });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user