mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 07:13:29 +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
@@ -87,18 +87,18 @@ describe("formatAdminAlertPayload — Withings re-auth", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("formatAdminAlertPayload — moodLog transient", () => {
|
||||
it("uses 'moodLog' display name and the 'investigate the upstream service.' action", () => {
|
||||
describe("formatAdminAlertPayload — non-Withings transient", () => {
|
||||
it("uses the provider's display name and the 'investigate the upstream service.' action", () => {
|
||||
const out = formatAdminAlertPayload({
|
||||
userId: "u-2",
|
||||
integration: "moodlog",
|
||||
integration: "nightscout",
|
||||
kind: "transient",
|
||||
message: "moodLog sync HTTP 502",
|
||||
message: "Nightscout sync HTTP 502",
|
||||
errorCode: "http_502",
|
||||
consecutiveFailures: 4,
|
||||
subjectLabel: "user@example.com",
|
||||
});
|
||||
expect(out.title).toBe("moodLog sync failing for user@example.com");
|
||||
expect(out.title).toBe("Nightscout sync failing for user@example.com");
|
||||
expect(out.message).toContain("Action: investigate the upstream service.");
|
||||
expect(out.message).toContain("(http_502)");
|
||||
});
|
||||
@@ -159,14 +159,14 @@ describe("formatAdminAlertPayload — metadata payload", () => {
|
||||
|
||||
const withoutCode = formatAdminAlertPayload({
|
||||
userId: "u-6",
|
||||
integration: "moodlog",
|
||||
integration: "nightscout",
|
||||
kind: "transient",
|
||||
message: "blip",
|
||||
errorCode: undefined,
|
||||
consecutiveFailures: 7,
|
||||
});
|
||||
expect(withoutCode.metadata).toEqual({
|
||||
integration: "moodlog",
|
||||
integration: "nightscout",
|
||||
affectedUserId: "u-6",
|
||||
consecutiveFailures: 7,
|
||||
errorCode: null,
|
||||
|
||||
@@ -223,9 +223,9 @@ describe("recordSyncFailure — at threshold", () => {
|
||||
} as never);
|
||||
await recordSyncFailure({
|
||||
userId: "u1",
|
||||
integration: "moodlog",
|
||||
integration: "nightscout",
|
||||
kind: "transient",
|
||||
message: "moodLog sync HTTP 502",
|
||||
message: "Nightscout sync HTTP 502",
|
||||
});
|
||||
expect(dispatchNotification).not.toHaveBeenCalled();
|
||||
});
|
||||
@@ -479,7 +479,7 @@ describe("markReauthRequired / markDisconnected / markReconnected", () => {
|
||||
vi.mocked(prisma.integrationStatus.upsert).mockResolvedValueOnce(
|
||||
{} as never,
|
||||
);
|
||||
await markDisconnected("u1", "moodlog");
|
||||
await markDisconnected("u1", "nightscout");
|
||||
const args = vi.mocked(prisma.integrationStatus.upsert).mock.calls[0][0];
|
||||
expect(args.update).toEqual({
|
||||
state: "disconnected",
|
||||
|
||||
@@ -35,7 +35,7 @@ describe("resolveSyncVerdict — the ladder", () => {
|
||||
state: "error_transient",
|
||||
lastSuccessAt: ago(55 * DAY),
|
||||
lastAttemptAt,
|
||||
cadence: INTEGRATION_CADENCE.moodlog,
|
||||
cadence: INTEGRATION_CADENCE.nightscout,
|
||||
now: NOW,
|
||||
});
|
||||
expect(result.verdict).toBe("stalled");
|
||||
|
||||
@@ -35,10 +35,9 @@ export type {
|
||||
} from "./sync-verdict";
|
||||
|
||||
/**
|
||||
* The `MeasurementSource` each sync integration's rows carry. `moodlog` is
|
||||
* absent — it writes `MoodEntry` rows, not `Measurement` rows, so it has no
|
||||
* per-metric measurement freshness. `strava` is absent from the measurement
|
||||
* map for the same reason and picks up its `WORKOUTS` entry below.
|
||||
* The `MeasurementSource` each sync integration's rows carry. `strava` is
|
||||
* absent — it writes `Workout` rows, not `Measurement` rows — and picks up its
|
||||
* `WORKOUTS` entry below.
|
||||
*/
|
||||
export const INTEGRATION_MEASUREMENT_SOURCE: Partial<
|
||||
Record<IntegrationKey, MeasurementSource>
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
/**
|
||||
* Per-(user, integration) sync-status bookkeeping.
|
||||
*
|
||||
* v1.4.15 Phase B2 introduces three responsibilities for every Withings /
|
||||
* moodLog sync attempt:
|
||||
* v1.4.15 Phase B2 introduces three responsibilities for every sync attempt:
|
||||
*
|
||||
* 1. Record success / failure timestamps so Settings → Integrations
|
||||
* can show "last sync 23 minutes ago" instead of guessing from
|
||||
@@ -23,9 +22,8 @@
|
||||
* sync entry-point still attempts on the next
|
||||
* run (network blip, 5xx, etc.).
|
||||
* error_reauth → refresh-token grant has revoked. `getValidToken`
|
||||
* / `syncMoodLogEntries` short-circuit until the
|
||||
* user reconnects. Cleared by markReconnected()
|
||||
* on the OAuth callback.
|
||||
* short-circuits until the user reconnects. Cleared
|
||||
* by markReconnected() on the OAuth callback.
|
||||
* disconnected → user clicked "Disconnect". Set explicitly by
|
||||
* the disconnect routes; clears any prior error
|
||||
* state.
|
||||
@@ -53,8 +51,7 @@ export type IntegrationKey =
|
||||
// `fitbit` transport, which sunsets Sept 2026.
|
||||
| "google-health"
|
||||
// v1.28.x — Strava OAuth workout source.
|
||||
| "strava"
|
||||
| "moodlog";
|
||||
| "strava";
|
||||
|
||||
/**
|
||||
* Failure kinds carried into `recordSyncFailure`.
|
||||
@@ -311,9 +308,8 @@ export async function isReauthRequired(
|
||||
/**
|
||||
* Record a successful sync. Resets the failure counter, clears any
|
||||
* prior error message, and (importantly) flips state back to
|
||||
* `connected` even from `error_reauth` — the moodLog flow re-enters
|
||||
* after the user re-supplies the apiKey, the Withings flow after the
|
||||
* OAuth callback writes a new refresh token.
|
||||
* `connected` even from `error_reauth` — the Withings flow re-enters
|
||||
* after the OAuth callback writes a new refresh token.
|
||||
*/
|
||||
export async function recordSyncSuccess(
|
||||
userId: string,
|
||||
@@ -862,7 +858,6 @@ const INTEGRATION_LABELS: Record<IntegrationKey, string> = {
|
||||
oura: "Oura",
|
||||
"google-health": "Google Health",
|
||||
strava: "Strava",
|
||||
moodlog: "moodLog",
|
||||
};
|
||||
|
||||
const FAILURE_KIND_COPY: Record<
|
||||
|
||||
@@ -115,14 +115,13 @@ export const INTEGRATION_CADENCE: Record<IntegrationKey, SyncCadence> = {
|
||||
oura: POLLED_CADENCE,
|
||||
"google-health": POLLED_CADENCE,
|
||||
strava: POLLED_CADENCE,
|
||||
moodlog: POLLED_CADENCE,
|
||||
};
|
||||
|
||||
export interface SyncVerdictInput {
|
||||
/**
|
||||
* Whether a live connection exists (an OAuth token, a connection row). Pass
|
||||
* `undefined` for providers that carry no connection concept — moodLog is
|
||||
* configured by URL alone — so the ladder falls through to `configured`.
|
||||
* `undefined` for providers that carry no connection concept, so the ladder
|
||||
* falls through to `configured`.
|
||||
*/
|
||||
connected?: boolean;
|
||||
/** Whether credentials / a URL are stored for this provider. */
|
||||
|
||||
Reference in new issue
Block a user