From e8bbe2c8f509de67181750f8451fae841b3fa195 Mon Sep 17 00:00:00 2001 From: Gareth George Date: Sat, 30 Mar 2024 09:08:32 +0000 Subject: [PATCH] fix: make notification title optional on discord notifications --- internal/hook/discordhook.go | 2 +- internal/hook/hookvars.go | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/internal/hook/discordhook.go b/internal/hook/discordhook.go index 871c0a38..a53e7c11 100644 --- a/internal/hook/discordhook.go +++ b/internal/hook/discordhook.go @@ -20,7 +20,7 @@ func (h *Hook) doDiscord(cmd *v1.Hook_ActionDiscord, vars HookVars, output io.Wr } request := Message{ - Content: "Backrest Notification\n" + payload, // leading newline looks better in discord. + Content: payload, // leading newline looks better in discord. } requestBytes, _ := json.Marshal(request) diff --git a/internal/hook/hookvars.go b/internal/hook/hookvars.go index d997628e..74957e31 100644 --- a/internal/hook/hookvars.go +++ b/internal/hook/hookvars.go @@ -116,7 +116,9 @@ func (v HookVars) renderTemplate(templ string) (string, error) { return buf.String(), nil } -var templateForSnapshotEnd = `Task: "{{ .Task }}" at {{ .FormatTime .CurTime }} +var templateForSnapshotEnd = ` +Backrest Notification for Snapshot End +Task: "{{ .Task }}" at {{ .FormatTime .CurTime }} Event: {{ .EventName .Event }} Repo: {{ .Repo.Id }} Plan: {{ .Plan.Id }} @@ -144,12 +146,16 @@ Backup Statistics: {{ end }} {{ end }}` -var templateForError = `Task: "{{ .Task }}" at {{ .FormatTime .CurTime }} +var templateForError = ` +Backrest Notification for Error +Task: "{{ .Task }}" at {{ .FormatTime .CurTime }} {{ if .Error -}} Error: {{ .Error }} {{ end }}` -var templateForSnapshotStart = `Task: "{{ .Task }}" at {{ .FormatTime .CurTime }} +var templateForSnapshotStart = ` +Backrest Notification for Snapshot Start +Task: "{{ .Task }}" at {{ .FormatTime .CurTime }} Event: {{ .EventName .Event }} Repo: {{ .Repo.Id }} Plan: {{ .Plan.Id }}