mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-14 22:50:51 +00:00
feat(integrations): remove the moodLog integration
Mood has been a first-class module here for a long time, with entries,
structured tags, rated factors and notes. The bridge to the external moodLog
service had nothing left to add, and its Settings card was withdrawn in
a56e6fe61 on the promise of a dedicated removal. This delivers it.
Removed: the hourly `moodlog-sync` queue, cron and handler binding; the
inbound webhook and its shared-secret handling; the reverse push and its four
call sites; the pull-sync module; the per-user credential routes and the
instance-wide toggle; the entry on the `/api/integrations/status` envelope,
the `IntegrationKey` union, the cadence map and the display-name table; the
boot-time secret rotation pass; 22 message keys per locale.
Migration 0271 drops the five `users` credential columns and
`app_settings.mood_log_global`, clears the ledger row for the provider, and
deletes the retired pg-boss schedule so no cron keeps enqueuing work no
handler drains.
Mood data is untouched. `mood_entries` is not named anywhere in the migration
and cannot be reached from it: the dropped columns carry no index, constraint
or foreign key, and `mood_entries.user_id` references `users(id)`, not any of
them. Rows the bridge imported keep `source = 'MOODLOG'`, and every read path
- list filter, source badge, exports, backups - still resolves that value.
`src/lib/validations/moodlog.ts` held the native mood-entry schemas alongside
the bridge's own; it is now `validations/mood.ts` and carries only the former.
This commit is contained in:
1 parent
4ed8c8f39b
commit
d0b45e36b3
106 files changed
+379
-3326
No files matched your search
@@ -40,7 +40,6 @@ vi.mock("@/lib/integrations/status", () => ({
|
||||
const perIntegrationLedger: Record<string, Record<string, unknown>> = {};
|
||||
|
||||
vi.mock("@/lib/withings/client", () => ({ hasActivityScope: () => false }));
|
||||
vi.mock("@/lib/moodlog-secret", () => ({ readMoodLogSecret: () => null }));
|
||||
|
||||
const polarAvailable = vi.fn(async () => true);
|
||||
const ouraAvailable = vi.fn(async () => false);
|
||||
@@ -178,13 +177,14 @@ describe("/api/integrations/status — sync-health verdict on every entry", () =
|
||||
}
|
||||
});
|
||||
|
||||
it("reports a configured, month-silent card-less provider as stalled", async () => {
|
||||
// The live incident, on the wire: moodLog has no Settings card, so this
|
||||
// entry is the only thing that can tell anyone the sync has stopped.
|
||||
it("reports a configured, month-silent provider as stalled", async () => {
|
||||
// The class the verdict exists for: the ledger state has been frozen
|
||||
// since the last write, so only the age of `lastAttemptAt` can say the
|
||||
// sync has stopped attempting.
|
||||
const lastAttemptAt = new Date(
|
||||
Date.now() - 28 * 24 * 60 * 60 * 1000,
|
||||
).toISOString();
|
||||
perIntegrationLedger.moodlog = {
|
||||
perIntegrationLedger.nightscout = {
|
||||
state: "error_transient",
|
||||
lastSuccessAt: new Date(
|
||||
Date.now() - 55 * 24 * 60 * 60 * 1000,
|
||||
@@ -192,23 +192,20 @@ describe("/api/integrations/status — sync-health verdict on every entry", () =
|
||||
lastAttemptAt,
|
||||
lastError: null,
|
||||
};
|
||||
userFind.mockResolvedValue({
|
||||
moodLogUrlEncrypted: "enc",
|
||||
moodLogEnabled: true,
|
||||
});
|
||||
userFind.mockResolvedValue({ nightscoutUrlEncrypted: "enc" });
|
||||
|
||||
const moodlog = (await fetchEntries()).find(
|
||||
(entry) => entry.integration === "moodlog",
|
||||
const nightscout = (await fetchEntries()).find(
|
||||
(entry) => entry.integration === "nightscout",
|
||||
)!;
|
||||
expect(moodlog.configured).toBe(true);
|
||||
expect(moodlog.syncHealth).toEqual({
|
||||
expect(nightscout.configured).toBe(true);
|
||||
expect(nightscout.syncHealth).toEqual({
|
||||
verdict: "stalled",
|
||||
since: lastAttemptAt,
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps an integration that attempted within the window off the stalled arm", async () => {
|
||||
perIntegrationLedger.moodlog = {
|
||||
perIntegrationLedger.nightscout = {
|
||||
state: "error_transient",
|
||||
lastSuccessAt: null,
|
||||
lastAttemptAt: new Date(
|
||||
@@ -216,12 +213,12 @@ describe("/api/integrations/status — sync-health verdict on every entry", () =
|
||||
).toISOString(),
|
||||
lastError: null,
|
||||
};
|
||||
userFind.mockResolvedValue({ moodLogUrlEncrypted: "enc" });
|
||||
userFind.mockResolvedValue({ nightscoutUrlEncrypted: "enc" });
|
||||
|
||||
const moodlog = (await fetchEntries()).find(
|
||||
(entry) => entry.integration === "moodlog",
|
||||
const nightscout = (await fetchEntries()).find(
|
||||
(entry) => entry.integration === "nightscout",
|
||||
)!;
|
||||
expect(moodlog.syncHealth!.verdict).toBe("failing");
|
||||
expect(nightscout.syncHealth!.verdict).toBe("failing");
|
||||
});
|
||||
|
||||
it("includes a nightscout entry with the fields the card's form reads", async () => {
|
||||
|
||||
Reference in new issue
Block a user