refactor(notifications): add more context in title (#296)
* refactor(notifications): add more context in title * chore: pr feedback
This commit is contained in:
parent
4671ebfc79
commit
7f71767ce7
1 changed files with 6 additions and 12 deletions
|
|
@ -369,18 +369,16 @@ function buildNotificationMessage(
|
||||||
snapshotId?: string;
|
snapshotId?: string;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
const date = new Date().toLocaleDateString();
|
const backupName = context.scheduleName ?? "backup";
|
||||||
const time = new Date().toLocaleTimeString();
|
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case "start":
|
case "start":
|
||||||
return {
|
return {
|
||||||
title: "🔵 Backup Started",
|
title: `Zerobyte ${backupName} 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 +386,7 @@ function buildNotificationMessage(
|
||||||
|
|
||||||
case "success":
|
case "success":
|
||||||
return {
|
return {
|
||||||
title: "✅ Backup Completed successfully",
|
title: `Zerobyte ${backupName} completed successfully`,
|
||||||
body: [
|
body: [
|
||||||
`Volume: ${context.volumeName}`,
|
`Volume: ${context.volumeName}`,
|
||||||
`Repository: ${context.repositoryName}`,
|
`Repository: ${context.repositoryName}`,
|
||||||
|
|
@ -397,7 +395,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 +402,7 @@ function buildNotificationMessage(
|
||||||
|
|
||||||
case "warning":
|
case "warning":
|
||||||
return {
|
return {
|
||||||
title: "! Backup completed with warnings",
|
title: `Zerobyte ${backupName} completed with warnings`,
|
||||||
body: [
|
body: [
|
||||||
`Volume: ${context.volumeName}`,
|
`Volume: ${context.volumeName}`,
|
||||||
`Repository: ${context.repositoryName}`,
|
`Repository: ${context.repositoryName}`,
|
||||||
|
|
@ -415,7 +412,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 +419,12 @@ function buildNotificationMessage(
|
||||||
|
|
||||||
case "failure":
|
case "failure":
|
||||||
return {
|
return {
|
||||||
title: "❌ Backup failed",
|
title: `Zerobyte ${backupName} 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"),
|
||||||
|
|
@ -437,12 +432,11 @@ function buildNotificationMessage(
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return {
|
return {
|
||||||
title: "Backup Notification",
|
title: `Zerobyte ${backupName} notification`,
|
||||||
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"),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue