refactor(notifications): add more context in title

This commit is contained in:
Nicolas Meienberger 2026-01-04 18:37:20 +01:00
parent a2ee223ee7
commit 71c3b48a0c

View file

@ -369,18 +369,14 @@ function buildNotificationMessage(
snapshotId?: string; snapshotId?: string;
}, },
) { ) {
const date = new Date().toLocaleDateString();
const time = new Date().toLocaleTimeString();
switch (event) { switch (event) {
case "start": case "start":
return { return {
title: "🔵 Backup Started", title: `Zerobyte ${context.scheduleName ? context.scheduleName : "backup"} started`,
body: [ body: [
`Volume: ${context.volumeName}`, `Volume: ${context.volumeName}`,
`Repository: ${context.repositoryName}`, `Repository: ${context.repositoryName}`,
context.scheduleName ? `Schedule: ${context.scheduleName}` : null, context.scheduleName ? `Schedule: ${context.scheduleName}` : null,
`Time: ${date} - ${time}`,
] ]
.filter(Boolean) .filter(Boolean)
.join("\n"), .join("\n"),
@ -388,7 +384,7 @@ function buildNotificationMessage(
case "success": case "success":
return { return {
title: "✅ Backup Completed successfully", title: `Zerobyte ${context.scheduleName ? context.scheduleName : "backup"} completed successfully`,
body: [ body: [
`Volume: ${context.volumeName}`, `Volume: ${context.volumeName}`,
`Repository: ${context.repositoryName}`, `Repository: ${context.repositoryName}`,
@ -397,7 +393,6 @@ function buildNotificationMessage(
context.filesProcessed !== undefined ? `Files: ${context.filesProcessed}` : null, context.filesProcessed !== undefined ? `Files: ${context.filesProcessed}` : null,
context.bytesProcessed ? `Size: ${context.bytesProcessed}` : null, context.bytesProcessed ? `Size: ${context.bytesProcessed}` : null,
context.snapshotId ? `Snapshot: ${context.snapshotId}` : null, context.snapshotId ? `Snapshot: ${context.snapshotId}` : null,
`Time: ${date} - ${time}`,
] ]
.filter(Boolean) .filter(Boolean)
.join("\n"), .join("\n"),
@ -405,7 +400,7 @@ function buildNotificationMessage(
case "warning": case "warning":
return { return {
title: "! Backup completed with warnings", title: `Zerobyte ${context.scheduleName ? context.scheduleName : "backup"} completed with warnings`,
body: [ body: [
`Volume: ${context.volumeName}`, `Volume: ${context.volumeName}`,
`Repository: ${context.repositoryName}`, `Repository: ${context.repositoryName}`,
@ -415,7 +410,6 @@ function buildNotificationMessage(
context.bytesProcessed ? `Size: ${context.bytesProcessed}` : null, context.bytesProcessed ? `Size: ${context.bytesProcessed}` : null,
context.snapshotId ? `Snapshot: ${context.snapshotId}` : null, context.snapshotId ? `Snapshot: ${context.snapshotId}` : null,
context.error ? `Warning: ${context.error}` : null, context.error ? `Warning: ${context.error}` : null,
`Time: ${date} - ${time}`,
] ]
.filter(Boolean) .filter(Boolean)
.join("\n"), .join("\n"),
@ -423,13 +417,12 @@ function buildNotificationMessage(
case "failure": case "failure":
return { return {
title: "❌ Backup failed", title: `Zerobyte ${context.scheduleName ? context.scheduleName : "backup"} failed`,
body: [ body: [
`Volume: ${context.volumeName}`, `Volume: ${context.volumeName}`,
`Repository: ${context.repositoryName}`, `Repository: ${context.repositoryName}`,
context.scheduleName ? `Schedule: ${context.scheduleName}` : null, context.scheduleName ? `Schedule: ${context.scheduleName}` : null,
context.error ? `Error: ${context.error}` : null, context.error ? `Error: ${context.error}` : null,
`Time: ${date} - ${time}`,
] ]
.filter(Boolean) .filter(Boolean)
.join("\n"), .join("\n"),
@ -442,7 +435,6 @@ function buildNotificationMessage(
`Volume: ${context.volumeName}`, `Volume: ${context.volumeName}`,
`Repository: ${context.repositoryName}`, `Repository: ${context.repositoryName}`,
context.scheduleName ? `Schedule: ${context.scheduleName}` : null, context.scheduleName ? `Schedule: ${context.scheduleName}` : null,
`Time: ${date} - ${time}`,
] ]
.filter(Boolean) .filter(Boolean)
.join("\n"), .join("\n"),