refactor(notifications): add more context in title (#296)

* refactor(notifications): add more context in title

* chore: pr feedback
This commit is contained in:
Nico 2026-01-05 20:46:36 +01:00 committed by GitHub
parent 21040d7d4c
commit ebbf3391a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

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