fix: make notification title optional on discord notifications

This commit is contained in:
Gareth George
2024-03-30 09:08:32 +00:00
parent fa6407cac2
commit e8bbe2c8f5
2 changed files with 10 additions and 4 deletions
+1 -1
View File
@@ -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)
+9 -3
View File
@@ -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 }}