Add emoji notification fields
This commit is contained in:
+52
-16
@@ -795,12 +795,15 @@ func notificationMessage(name, repository string, run model.Run, now time.Time)
|
||||
if status == "" {
|
||||
status = run.Status
|
||||
}
|
||||
lines := []string{"📊 URBM-Zusammenfassung", "", "Status: " + status}
|
||||
if name != "" {
|
||||
lines = append(lines, "Job: "+name)
|
||||
}
|
||||
lines := []string{"📊 Backup-Zusammenfassung", ""}
|
||||
if repository != "" {
|
||||
lines = append(lines, "Repository: "+repository)
|
||||
lines = append(lines, "📦 Repository: "+repository)
|
||||
}
|
||||
if name != "" {
|
||||
lines = append(lines, "🗂️ Job: "+name)
|
||||
}
|
||||
if run.TaskType == "backup" && run.SnapshotID != "" {
|
||||
lines = append(lines, "📸 Snapshot: "+shortID(run.SnapshotID))
|
||||
}
|
||||
if run.StartedAt != nil {
|
||||
finished := now
|
||||
@@ -808,33 +811,66 @@ func notificationMessage(name, repository string, run model.Run, now time.Time)
|
||||
finished = *run.FinishedAt
|
||||
}
|
||||
if duration := finished.Sub(*run.StartedAt); duration >= 0 {
|
||||
lines = append(lines, "Dauer: "+formatDuration(duration))
|
||||
lines = append(lines, "", "⏱️ Dauer: "+formatDuration(duration))
|
||||
}
|
||||
}
|
||||
if (run.TaskType == "backup" || run.TaskType == "rsync") && (run.Status == "success" || run.Status == "warning") {
|
||||
if run.TaskType == "backup" && run.SnapshotID != "" {
|
||||
lines = append(lines, "Snapshot: "+run.SnapshotID)
|
||||
}
|
||||
lines = append(lines,
|
||||
"Verarbeitete Daten: "+formatBytes(run.BytesProcessed),
|
||||
fmt.Sprintf("Verarbeitete Dateien: %d", run.FilesProcessed),
|
||||
fmt.Sprintf("📂 Dateien: %d verarbeitet", run.FilesProcessed),
|
||||
"💾 Verarbeitet: "+formatBytes(run.BytesProcessed),
|
||||
)
|
||||
if run.TaskType == "backup" {
|
||||
lines = append(lines,
|
||||
"Neu gespeichert: "+formatBytes(run.BytesAdded),
|
||||
fmt.Sprintf("Neue Dateien: %d", run.FilesNew),
|
||||
fmt.Sprintf("Geänderte Dateien: %d", run.FilesChanged),
|
||||
fmt.Sprintf("➕ Neu: %d Dateien", run.FilesNew),
|
||||
fmt.Sprintf("✏️ Geändert: %d Dateien", run.FilesChanged),
|
||||
"📤 Neu gespeichert: "+formatBytes(run.BytesAdded),
|
||||
)
|
||||
} else {
|
||||
lines = append(lines, "Kopierte Daten: "+formatBytes(run.BytesAdded))
|
||||
lines = append(lines, "📤 Kopiert: "+formatBytes(run.BytesAdded))
|
||||
}
|
||||
}
|
||||
lines = append(lines, "", "🔐 Ziel: "+notificationTargetLabel(run.TaskType), statusIcon(run.Status)+" Status: "+status)
|
||||
if run.Message != "" && run.Message != "backup completed" && run.Message != "rsync completed" {
|
||||
lines = append(lines, "Details: "+run.Message)
|
||||
lines = append(lines, "⚠️ Details: "+run.Message)
|
||||
}
|
||||
return strings.Join(lines, "\n")
|
||||
}
|
||||
|
||||
func statusIcon(status string) string {
|
||||
switch status {
|
||||
case "success":
|
||||
return "✅"
|
||||
case "warning":
|
||||
return "⚠️"
|
||||
case "failed":
|
||||
return "❌"
|
||||
default:
|
||||
return "ℹ️"
|
||||
}
|
||||
}
|
||||
|
||||
func notificationTargetLabel(taskType string) string {
|
||||
switch taskType {
|
||||
case "backup":
|
||||
return "Restic Repository"
|
||||
case "rsync":
|
||||
return "Rsync Ziel"
|
||||
case "restore":
|
||||
return "Restore Ziel"
|
||||
case "check", "prune":
|
||||
return "Restic Repository"
|
||||
default:
|
||||
return "URBM"
|
||||
}
|
||||
}
|
||||
|
||||
func shortID(value string) string {
|
||||
if len(value) <= 12 {
|
||||
return value
|
||||
}
|
||||
return value[:12]
|
||||
}
|
||||
|
||||
func formatBytes(value int64) string {
|
||||
const unit = int64(1024)
|
||||
if value < unit {
|
||||
|
||||
Reference in New Issue
Block a user