Nextcloud cron and Nextcloud's own checks; bulk close and open again
Nextcloud: its own "Cron last run" setup check (GET /settings/setupcheck, Nextcloud 28+, found by class name) raises an alert when background jobs have stopped; other checks that report an error are one alert, warnings are shown on the page. The core version Nextcloud says is available is shown too. Before 28, cron and the checks are unknown, never "fine". Alerts page: bulk Close... (one reason, written on each incident, undoable) and Open again. Bulk Wake now leaves closed alerts alone. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5ae61a1ece
commit
65214f6f0f
25 files changed
+8108
-35
No files matched your search
@@ -4,7 +4,8 @@ import { requireAuth, requireRole } from "../auth/middleware.js";
|
||||
import { AckError, MAX_HOURS, MAX_NOTE } from "../services/alertAcks.js";
|
||||
import { SnoozeError } from "../services/alertSnoozes.js";
|
||||
import { recordAudit } from "../services/audit.js";
|
||||
import { acknowledgeAlerts, BulkInputError, changeAssets, changeServerTag, MAX_BULK, restoreAcks, restoreAssets, restoreServerParents, restoreSnoozes, setServerParents, setServerTags, silenceTargets, snoozeAlerts, targetsOfAlerts, undoSilence, unacknowledgeAlerts, unsnoozeAlerts } from "../services/bulkActions.js";
|
||||
import { acknowledgeAlerts, BulkInputError, changeAssets, closeAlerts, reopenAlerts, changeServerTag, MAX_BULK, restoreAcks, restoreAssets, restoreServerParents, restoreSnoozes, setServerParents, setServerTags, silenceTargets, snoozeAlerts, targetsOfAlerts, undoSilence, unacknowledgeAlerts, unsnoozeAlerts } from "../services/bulkActions.js";
|
||||
import { addNote, openIncidentIds } from "../services/incidents.js";
|
||||
import { InvalidTagError } from "../services/serverTags.js";
|
||||
import { asyncHandler } from "../utils/asyncHandler.js";
|
||||
|
||||
@@ -109,7 +110,10 @@ const alertsBody = z.discriminatedUnion("action", [
|
||||
/** When they should come back, as a date and time with its zone. */
|
||||
z.object({ action: z.literal("snooze"), alertIds: stringIds, until: z.string().min(1).max(40) }),
|
||||
z.object({ action: z.literal("unsnooze"), alertIds: stringIds }),
|
||||
z.object({ action: z.literal("restore_snoozes"), items: z.array(z.object({ alertId: z.string().min(1).max(600), previous: snoozeRecord.nullable() })).min(1).max(MAX_BULK) }),
|
||||
/** "Dealt with, or accepted": hidden with no end, until each gets worse. The note is written on each one's incident. */
|
||||
z.object({ action: z.literal("close"), alertIds: stringIds, note: z.string().max(500).nullable().optional() }),
|
||||
z.object({ action: z.literal("reopen"), alertIds: stringIds }),
|
||||
z.object({ action: z.literal("restore_snoozes"), items: z.array(z.object({ alertId: z.string().min(1).max(600), previous: snoozeRecord.nullable() })).min(1).max(MAX_BULK), closed: z.boolean().optional() }),
|
||||
z.object({ action: z.literal("acknowledge"), alertIds: stringIds, note: z.string().max(MAX_NOTE).default(""), assigneeId: z.number().int().positive().nullable().default(null), hours: z.number().int().min(1).max(MAX_HOURS).nullable().default(null) }),
|
||||
z.object({ action: z.literal("unacknowledge"), alertIds: stringIds }),
|
||||
z.object({ action: z.literal("restore_acks"), items: z.array(z.object({ alertId: z.string().min(1).max(600), previous: previousAck })).min(1).max(MAX_BULK) }),
|
||||
@@ -151,9 +155,43 @@ alertsBulkRouter.post("/", asyncHandler(async (req, res) => {
|
||||
await recordAudit({ actor, category: "alert", action: "bulk_unsnooze", detail: { changed: r.changed, alerts: detailIds(body.alertIds) } });
|
||||
return res.json(r);
|
||||
}
|
||||
case "close": {
|
||||
const note = (body.note ?? "").trim() === "" ? null : (body.note ?? "").trim();
|
||||
const who = nameOf(req);
|
||||
const r = await closeAlerts(body.alertIds, note, who);
|
||||
// Each one's incident says it was closed, by whom and why, as when one is closed alone.
|
||||
const open = await openIncidentIds((r.undo?.items ?? []).map((i) => i.alertId));
|
||||
const together = r.changed > 1 ? ` (closed together with ${r.changed - 1} other${r.changed === 2 ? "" : "s"})` : "";
|
||||
for (const item of r.undo?.items ?? []) {
|
||||
const incidentId = open.get(item.alertId);
|
||||
if (incidentId) await addNote(incidentId, who, (note ? "Closed: " + note : "Closed without a note.") + together);
|
||||
}
|
||||
await recordAudit({ actor, category: "alert", action: "bulk_close", detail: { changed: r.changed, note, alerts: detailIds(body.alertIds) } });
|
||||
return res.json(r);
|
||||
}
|
||||
case "reopen": {
|
||||
const who = nameOf(req);
|
||||
const r = await reopenAlerts(body.alertIds);
|
||||
const open = await openIncidentIds((r.undo?.items ?? []).map((i) => i.alertId));
|
||||
for (const item of r.undo?.items ?? []) {
|
||||
const incidentId = open.get(item.alertId);
|
||||
if (incidentId) await addNote(incidentId, who, "Opened again.");
|
||||
}
|
||||
await recordAudit({ actor, category: "alert", action: "bulk_reopen", detail: { changed: r.changed, alerts: detailIds(body.alertIds) } });
|
||||
return res.json(r);
|
||||
}
|
||||
case "restore_snoozes": {
|
||||
const changed = await restoreSnoozes(body.items);
|
||||
await recordAudit({ actor, category: "alert", action: "bulk_undo", detail: { changed, what: "snooze" } });
|
||||
if (body.closed) {
|
||||
// The undo of closing several: those that are open again say so on their incidents.
|
||||
const reopened = body.items.filter((i) => i.previous?.kind !== "closed").map((i) => i.alertId);
|
||||
const open = await openIncidentIds(reopened);
|
||||
for (const alertId of reopened) {
|
||||
const incidentId = open.get(alertId);
|
||||
if (incidentId) await addNote(incidentId, nameOf(req), "Opened again (closing it was undone).");
|
||||
}
|
||||
}
|
||||
await recordAudit({ actor, category: "alert", action: "bulk_undo", detail: { changed, what: body.closed ? "close" : "snooze" } });
|
||||
return res.json({ changed, skipped: [], undo: null });
|
||||
}
|
||||
case "silence": {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { eq } from "drizzle-orm";
|
||||
import { db } from "../db/client.js";
|
||||
import { integrations, nextcloudState } from "../db/schema.js";
|
||||
import { requireAuth } from "../auth/middleware.js";
|
||||
import { isNextcloudFresh, nextcloudProblems, nextcloudSyncStatuses } from "../services/nextcloudSync.js";
|
||||
import { isNextcloudFresh, nextcloudProblems, nextcloudSyncStatuses, setupIssuesOf } from "../services/nextcloudSync.js";
|
||||
import { asyncHandler } from "../utils/asyncHandler.js";
|
||||
|
||||
export const nextcloudRouter = Router();
|
||||
@@ -40,6 +40,9 @@ nextcloudRouter.get("/", asyncHandler(async (_req, res) => {
|
||||
files: state.files,
|
||||
active24h: state.active24h,
|
||||
appUpdates: state.appUpdates,
|
||||
coreUpdate: state.coreUpdate,
|
||||
cron: state.cronState ? { state: state.cronState, text: state.cronText } : null,
|
||||
setupIssues: setupIssuesOf(state),
|
||||
updatedAt: state.updatedAt,
|
||||
}
|
||||
: null,
|
||||
|
||||
Reference in new issue
Block a user