From 8c427cc5717cc05b113ce12725ccf7ab193bf07f Mon Sep 17 00:00:00 2001 From: ChaoticByte Date: Thu, 19 Oct 2023 20:50:32 +0200 Subject: [PATCH] Improved the default templates --- template.go | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/template.go b/template.go index 56cb46d..beda4ac 100644 --- a/template.go +++ b/template.go @@ -7,23 +7,26 @@ import ( "text/template" ) -const DEFAULT_SUBJECT_TEMPLATE = "{{ if .Status }}{{.Status}} {{ end }}[{{.Classification}}] {{.Title}}" -const DEFAULT_BODY_TEMPLATE = `{{.Name}} -{{.PortalUrl}} +const DEFAULT_SUBJECT_TEMPLATE = "[{{ .Classification }}] {{ .Title }}" +const DEFAULT_BODY_TEMPLATE = `{{ if .Status }}[{{ .Status }}] {{ end }}{{ .Name }} +-> {{ .PortalUrl }} +{{- if eq .NoPatch "true" }} -Published: {{.Published}} -{{ if gt .Basescore -1 }}Basescore: {{.Basescore}} -{{ end -}} -{{ if eq .NoPatch "true" }}There is no patch available at the moment! -{{ end }} -Affected Products: -{{ range $product := .ProductNames }} - {{ $product }} -{{ else }} unknown -{{ end }} -Assigned CVEs: -{{ range $cve := .Cves }} - {{ $cve }} -{{ else }} unknown -{{ end }}` +No patch available! +{{- end }} +{{ if gt .Basescore -1 }} +Basescore: {{ .Basescore }}{{- end }} +Published: {{ .Published }} +{{- if .ProductNames }} + +Affected Products:{{ range $product := .ProductNames }} + - {{ $product }} +{{- end }}{{ end }} +{{- if .Cves }} + +Assigned CVEs:{{ range $cve := .Cves }} + - {{ $cve }} -> https://www.cve.org/CVERecord?id={{ $cve }} +{{- end }}{{ end }}` type MailTemplateConfig struct { SubjectTemplate string `json:"subject"`