Build the Settings module: notification channels, event toggles, DNS badge colors

The Settings page was a "coming soon" placeholder. Port Sloth Manager's
settings feature set: Gotify/ntfy/SMTP/webhook notification channels
(each with its own test-send button), per-event toggles (DNS record
added/updated/deleted, a daily secret-expiry digest with configurable
time/timezone), and per-provider DNS badge color customization.

Settings persist in the existing `settings` key/value table via a new
settingsStore service; a notify service fans a message out to every
enabled channel. DNS record add/update/delete now fire notifications,
and a node-schedule job re-arms itself whenever the notification
settings change. Removed the now-superseded GOTIFY_URL/GOTIFY_TOKEN
env vars in favor of in-app configuration.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5 committed 2026-09-15 12:14:05 +02:00
1 parent 3a53a86ce0
commit 3255314402
16 files changed
+1272 -23

No files matched your search

+33
View File
@@ -14,6 +14,16 @@ import {
import { createDnsAdapter } from "../dns/registry.js";
import { loadDnsProviderConfig, getDnsAdapterForProvider } from "../dns/loadProvider.js";
import { asyncHandler } from "../utils/asyncHandler.js";
import { notifyDnsRecordAdded, notifyDnsRecordUpdated, notifyDnsRecordDeleted } from "../services/notify.js";
async function zoneNameFor(providerId: number, zoneId: string): Promise<string> {
const [zone] = await db
.select()
.from(dnsZonesCache)
.where(and(eq(dnsZonesCache.providerId, providerId), eq(dnsZonesCache.zoneId, zoneId)))
.limit(1);
return zone?.zoneName ?? zoneId;
}
export const dnsRouter = Router();
@@ -383,6 +393,9 @@ dnsRouter.post("/providers/:id/zones/:zoneId/records", requireRole("operator"),
targetId: result.id,
detail: { providerId, zoneId, name: result.name, type: result.type },
});
notifyDnsRecordAdded(found.provider.name, await zoneNameFor(providerId, zoneId), result).catch((err) =>
console.error("[dns] add-record notification failed:", err),
);
res.status(201).json({ record: result });
} catch (err) {
@@ -433,6 +446,9 @@ dnsRouter.put("/providers/:id/zones/:zoneId/records/:recordId", requireRole("ope
targetId: result.id,
detail: { providerId, zoneId, name: result.name, type: result.type },
});
notifyDnsRecordUpdated(found.provider.name, await zoneNameFor(providerId, zoneId), result).catch((err) =>
console.error("[dns] update-record notification failed:", err),
);
res.json({ record: result });
} catch (err) {
@@ -448,6 +464,18 @@ dnsRouter.delete("/providers/:id/zones/:zoneId/records/:recordId", requireRole("
if (!found) return res.status(404).json({ error: "not_found" });
try {
const [existingCached] = await db
.select()
.from(dnsRecordsCache)
.where(
and(
eq(dnsRecordsCache.providerId, providerId),
eq(dnsRecordsCache.zoneId, zoneId),
eq(dnsRecordsCache.recordId, recordId),
),
)
.limit(1);
await found.adapter.deleteRecord(zoneId, recordId);
await db
.delete(dnsRecordsCache)
@@ -467,6 +495,11 @@ dnsRouter.delete("/providers/:id/zones/:zoneId/records/:recordId", requireRole("
targetId: recordId,
detail: { providerId, zoneId },
});
if (existingCached) {
notifyDnsRecordDeleted(found.provider.name, await zoneNameFor(providerId, zoneId), existingCached).catch((err) =>
console.error("[dns] delete-record notification failed:", err),
);
}
res.status(204).end();
} catch (err) {