Skip to content

Commit dcc07c8

Browse files
committed
fix(publisher): guard draft service alerts from publishing; add boundary tests
1 parent be787e3 commit dcc07c8

3 files changed

Lines changed: 24 additions & 1 deletion

File tree

packages/publisher/src/mappers.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,9 @@ export function noticeToSpec(
559559
const title = str(row, "title");
560560
if (!id || !title) return null;
561561

562+
// Draft service alerts do not publish — resolved alerts are edits, not filtered.
563+
if (source === "service_alert" && str(row, "status") === "draft") return null;
564+
562565
const d = `${source === "service_alert" ? "alert" : "announcement"}:${id}`;
563566
const active = source === "service_alert" ? row["status"] === "active" : row["is_active"] === true;
564567
const tags: string[][] = [

packages/publisher/src/sync.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ export async function buildSpecs(
217217
if (deps.datasets.includes("notices")) {
218218
const alerts = await deps.fetchRows(
219219
"service_alerts",
220-
"select=id,title,description,severity,status,updated_at,created_at",
220+
"select=id,title,description,severity,status,updated_at,created_at&status=neq.draft",
221221
);
222222
for (const row of alerts) {
223223
const spec = noticeToSpec(row, "service_alert");

packages/publisher/test/mappers.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,4 +462,24 @@ describe("civic notices (kind 32102)", () => {
462462
assert.equal(spec!.d, "announcement:n1");
463463
assert.equal(spec!.content, "Donnerstag 16 Uhr");
464464
});
465+
466+
it("noticeToSpec: draft service alerts do NOT publish — returns null", () => {
467+
const spec = noticeToSpec(
468+
{ id: "a2", title: "Entwurf", description: "Noch nicht bereit",
469+
severity: "warning", status: "draft", updated_at: "2026-07-02T10:00:00Z" },
470+
"service_alert",
471+
);
472+
assert.equal(spec, null);
473+
});
474+
475+
it("noticeToSpec: resolved service alerts DO publish as edits — not filtered", () => {
476+
const spec = noticeToSpec(
477+
{ id: "a3", title: "Gelöst", description: "Behoben",
478+
severity: "warning", status: "resolved", updated_at: "2026-07-02T10:00:00Z" },
479+
"service_alert",
480+
);
481+
assert.ok(spec);
482+
assert.equal(spec!.kind, 32102);
483+
assert.equal(spec!.tags.find((t) => t[0] === "status")?.[1], "resolved");
484+
});
465485
});

0 commit comments

Comments
 (0)