mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 07:42:23 +00:00
feat(cycle): predicted-period notifications + reproductive-data privacy docs
Add two cycle reminders through the existing notification cascade and the honest self-hosting privacy framing for reproductive-health data. Notifications: - New event types CYCLE_PERIOD_SOON (fires ~2 days before the predicted next-period start, from the cached prediction) and CYCLE_PERIOD_CONFIRM (a gentle "did your period start?" on/after the predicted start while no period is logged, within a short grace window). Both default OFF and are gated again on cycleTrackingEnabled — opt in twice for a sensitive surface. - A 15-minute pg-boss cron mirrors the mood-reminder worker: it scans users with cycle tracking enabled + predictionEnabled, computes who is in-window from the cached forecast, and dispatches one push per event per local day. Idempotency anchors on the push_attempts ledger (no new table). The queue is declared, registered in allQueues, scheduled, and wired to a boss.work handler, with a source-grep guard so it cannot ship unregistered. - Honours notificationPrefs.cycle.clientManaged (skip the server push when the device owns local reminders, with a suppressed annotation, mirroring the medication path) and CycleProfile.discreetNotifications (generic "HealthLog reminder" body so no cycle event is named on the lock screen). - Every attempt is recorded in push_attempts via the unchanged dispatcher. Privacy / disclaimer: - docs/self-hosting/reproductive-health-data.md — the "no cloud vendor to subpoena" framing with the honest residual-threat caveat (your own host, provider, backups, and devices remain part of the surface), citing the 2021 FTC settlement and 2025 verdict as public record only. - docs/security/cycle-data-threat-model.md — a compact "protects against / does not protect against" note, plus README pointers. - CyclePredictionDisclaimer component (reusing the GLP-1 estimate-disclaimer pattern) for every fertility/prediction surface: descriptive, not a contraceptive method, not medical advice, never a safe-to-have-unprotected -sex claim. 6-locale copy under cycle.disclaimer. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
77a652a47c
commit
6fdbb8d889
18 files changed
+1372
-8
No files matched your search
@@ -90,6 +90,7 @@ describe("GET /api/auth/me/notification-prefs", () => {
|
||||
expect(env.data).toEqual({
|
||||
medication: { clientManaged: false, deliveryDefault: "server" },
|
||||
mood: { reminderHour: 22 },
|
||||
cycle: { clientManaged: false },
|
||||
});
|
||||
});
|
||||
|
||||
@@ -109,6 +110,7 @@ describe("GET /api/auth/me/notification-prefs", () => {
|
||||
expect(env.data).toEqual({
|
||||
medication: { clientManaged: true, deliveryDefault: "server" },
|
||||
mood: { reminderHour: 22 },
|
||||
cycle: { clientManaged: false },
|
||||
});
|
||||
});
|
||||
|
||||
@@ -130,6 +132,7 @@ describe("GET /api/auth/me/notification-prefs", () => {
|
||||
expect(env.data).toEqual({
|
||||
medication: { clientManaged: false, deliveryDefault: "server" },
|
||||
mood: { reminderHour: 22 },
|
||||
cycle: { clientManaged: false },
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -162,6 +165,7 @@ describe("PATCH /api/auth/me/notification-prefs", () => {
|
||||
expect(env.data).toEqual({
|
||||
medication: { clientManaged: true, deliveryDefault: "server" },
|
||||
mood: { reminderHour: 22 },
|
||||
cycle: { clientManaged: false },
|
||||
});
|
||||
|
||||
expect(prisma.user.update).toHaveBeenCalledWith({
|
||||
@@ -170,6 +174,7 @@ describe("PATCH /api/auth/me/notification-prefs", () => {
|
||||
notificationPrefs: {
|
||||
medication: { clientManaged: true, deliveryDefault: "server" },
|
||||
mood: { reminderHour: 22 },
|
||||
cycle: { clientManaged: false },
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -182,10 +187,12 @@ describe("PATCH /api/auth/me/notification-prefs", () => {
|
||||
previous: {
|
||||
medication: { clientManaged: false, deliveryDefault: "server" },
|
||||
mood: { reminderHour: 22 },
|
||||
cycle: { clientManaged: false },
|
||||
},
|
||||
next: {
|
||||
medication: { clientManaged: true, deliveryDefault: "server" },
|
||||
mood: { reminderHour: 22 },
|
||||
cycle: { clientManaged: false },
|
||||
},
|
||||
changed: ["medication"],
|
||||
}),
|
||||
@@ -246,6 +253,7 @@ describe("PATCH /api/auth/me/notification-prefs", () => {
|
||||
notificationPrefs: {
|
||||
medication: { clientManaged: true, deliveryDefault: "server" },
|
||||
mood: { reminderHour: 22 },
|
||||
cycle: { clientManaged: false },
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -270,6 +278,7 @@ describe("PATCH /api/auth/me/notification-prefs", () => {
|
||||
expect(env.data).toEqual({
|
||||
medication: { clientManaged: true, deliveryDefault: "server" },
|
||||
mood: { reminderHour: 22 },
|
||||
cycle: { clientManaged: false },
|
||||
});
|
||||
|
||||
expect(prisma.user.update).toHaveBeenCalledWith({
|
||||
@@ -278,6 +287,7 @@ describe("PATCH /api/auth/me/notification-prefs", () => {
|
||||
notificationPrefs: {
|
||||
medication: { clientManaged: true, deliveryDefault: "server" },
|
||||
mood: { reminderHour: 22 },
|
||||
cycle: { clientManaged: false },
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -305,6 +315,7 @@ describe("PATCH /api/auth/me/notification-prefs", () => {
|
||||
notificationPrefs: {
|
||||
medication: { clientManaged: false, deliveryDefault: "server" },
|
||||
mood: { reminderHour: 9 },
|
||||
cycle: { clientManaged: false },
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user