Skip to content

Commit

Permalink
fix: make notification title optional on discord notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
garethgeorge committed Mar 30, 2024
1 parent fa6407c commit e8bbe2c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/hook/discordhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 9 additions & 3 deletions internal/hook/hookvars.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand Down

0 comments on commit e8bbe2c

Please sign in to comment.