diff --git a/internal/mail/mail_test.go b/internal/mail/mail_test.go index c195ab9..b70a9d2 100644 --- a/internal/mail/mail_test.go +++ b/internal/mail/mail_test.go @@ -121,3 +121,32 @@ func TestSMTP_dialFailure(t *testing.T) { t.Fatalf("got %v", err) } } + +// Every mail carries the company signature for the no-reply sender, in the +// mail's language, in both bodies. +func TestRender_signature(t *testing.T) { + for _, kind := range []string{KindDocumentPublished, KindFindingsNew} { + for _, c := range []struct{ lang, greeting, team string }{ + {"de", "Mit freundlichen Grüßen", "Ihr BreakPilot-Team"}, + {"en", "Kind regards", "Your BreakPilot team"}, + } { + m, err := Render(kind, c.lang, View{Tenant: "acme", URL: "https://app/acme", + D: map[string]any{"title": "T", "target_name": "fw", "new_count": 2}}) + if err != nil { + t.Fatal(err) + } + for _, body := range []string{m.Text, m.HTML} { + for _, want := range []string{c.greeting, c.team, "Breakpilot GmbH", "78351 Bodman-Ludwigshafen", + "noreply@breakpilot.com", "kontakt@breakpilot.com", "DE464808363", "HRB 736403", "Sharang Deepak Parnerkar"} { + if !strings.Contains(body, want) { + t.Errorf("%s/%s: %q missing", kind, c.lang, want) + } + } + } + // The signature comes before the "why you get this" footer. + if strings.Index(m.Text, c.team) > strings.Index(m.Text, "\n--\n") { + t.Errorf("%s/%s: signature after the footer", kind, c.lang) + } + } + } +} diff --git a/internal/mail/render.go b/internal/mail/render.go index 8b748ba..0e412aa 100644 --- a/internal/mail/render.go +++ b/internal/mail/render.go @@ -45,7 +45,7 @@ func Render(kind, locale string, v View) (Message, error) { v.D = map[string]any{} } file := "templates/" + locale + "_" + kind + ".tmpl" - tt, err := texttpl.ParseFS(templates, file) + tt, err := texttpl.ParseFS(templates, "templates/signature.tmpl", file) if err != nil { return Message{}, err } @@ -57,7 +57,7 @@ func Render(kind, locale string, v View) (Message, error) { return Message{}, err } v.Subject = strings.Join(strings.Fields(subj.String()), " ") - ht, err := htmltpl.ParseFS(templates, "templates/layout.html", file) + ht, err := htmltpl.ParseFS(templates, "templates/layout.html", "templates/signature.tmpl", file) if err != nil { return Message{}, err } diff --git a/internal/mail/templates/de_document.published.tmpl b/internal/mail/templates/de_document.published.tmpl index 572f08f..4e44a70 100644 --- a/internal/mail/templates/de_document.published.tmpl +++ b/internal/mail/templates/de_document.published.tmpl @@ -16,6 +16,8 @@ BreakPilot hat im Arbeitsbereich {{.Tenant}} ein Dokument veröffentlicht: Sie finden es im Portal unter "Dokumente": {{.URL}} +{{template "signature_text" .}} + -- Sie erhalten diese E-Mail, weil Sie im Arbeitsbereich {{.Tenant}} Unterlagen einsehen dürfen. BreakPilot GmbH · https://breakpilot.com/impressum{{end}} diff --git a/internal/mail/templates/de_findings.new.tmpl b/internal/mail/templates/de_findings.new.tmpl index b453e06..57ebff5 100644 --- a/internal/mail/templates/de_findings.new.tmpl +++ b/internal/mail/templates/de_findings.new.tmpl @@ -24,6 +24,8 @@ Im Befund sehen Sie Fundstelle, Schweregrad und, soweit zugeordnet, die betroffe Befunde ansehen: {{.URL}} +{{template "signature_text" .}} + -- Sie erhalten diese E-Mail, weil Sie den Arbeitsbereich {{.Tenant}} verwalten. Breakpilot GmbH · https://breakpilot.com/impressum{{end}} diff --git a/internal/mail/templates/en_document.published.tmpl b/internal/mail/templates/en_document.published.tmpl index 1772b18..dbf3c4f 100644 --- a/internal/mail/templates/en_document.published.tmpl +++ b/internal/mail/templates/en_document.published.tmpl @@ -16,6 +16,8 @@ BreakPilot published a document in the {{.Tenant}} workspace: You find it in the portal under "Documents": {{.URL}} +{{template "signature_text" .}} + -- You receive this email because you may view documents in the {{.Tenant}} workspace. BreakPilot GmbH · https://breakpilot.com/impressum{{end}} diff --git a/internal/mail/templates/en_findings.new.tmpl b/internal/mail/templates/en_findings.new.tmpl index 66da66b..ee9c957 100644 --- a/internal/mail/templates/en_findings.new.tmpl +++ b/internal/mail/templates/en_findings.new.tmpl @@ -24,6 +24,8 @@ Each finding shows where it is, how severe it is and, where mapped, the CRA requ View the findings: {{.URL}} +{{template "signature_text" .}} + -- You receive this email because you administer the {{.Tenant}} workspace. Breakpilot GmbH · https://breakpilot.com/impressum{{end}} diff --git a/internal/mail/templates/layout.html b/internal/mail/templates/layout.html index 0810a45..6bfb3d5 100644 --- a/internal/mail/templates/layout.html +++ b/internal/mail/templates/layout.html @@ -16,6 +16,9 @@ {{template "button" .}} + +{{template "signature_html" .}} + {{template "footer" .}}
Breakpilot GmbH · {{if eq .Lang "de"}}Impressum{{else}}Imprint{{end}} · {{if eq .Lang "de"}}Datenschutz{{else}}Privacy{{end}} diff --git a/internal/mail/templates/signature.tmpl b/internal/mail/templates/signature.tmpl new file mode 100644 index 0000000..82c9652 --- /dev/null +++ b/internal/mail/templates/signature.tmpl @@ -0,0 +1,33 @@ +{{/* The company signature of every mail, modelled on the founders' signature + (Brand_Assets/Email_Signature) but for the no-reply sender. Company data + as in the website's Impressum. */}} +{{define "signature_html"}} +
+
{{if eq .Lang "de"}}Mit freundlichen Grüßen{{else}}Kind regards{{end}}
+
{{if eq .Lang "de"}}Ihr BreakPilot-Team{{else}}Your BreakPilot team{{end}}
+
Breakpilot GmbH
+
In Steinäckern 16
+
78351 Bodman-Ludwigshafen
+
E-Mail: noreply@breakpilot.com ({{if eq .Lang "de"}}keine Antworten{{else}}no replies{{end}})
+
{{if eq .Lang "de"}}Kontakt{{else}}Contact{{end}}: kontakt@breakpilot.com
+
Web: www.breakpilot.com
+
 
+
USt.-ID: DE464808363
+
Amtsgericht Freiburg, HRB 736403
+
{{if eq .Lang "de"}}Geschäftsführer{{else}}Managing directors{{end}}: Benjamin Bönisch {{if eq .Lang "de"}}und{{else}}and{{end}} Sharang Deepak Parnerkar
+
{{end}} +{{define "signature_text"}}{{if eq .Lang "de"}}Mit freundlichen Grüßen +Ihr BreakPilot-Team{{else}}Kind regards +Your BreakPilot team{{end}} + +Breakpilot GmbH +In Steinäckern 16 +78351 Bodman-Ludwigshafen + +E-Mail: noreply@breakpilot.com ({{if eq .Lang "de"}}keine Antworten{{else}}no replies{{end}}) +{{if eq .Lang "de"}}Kontakt{{else}}Contact{{end}}: kontakt@breakpilot.com +Web: www.breakpilot.com + +USt.-ID: DE464808363 +Amtsgericht Freiburg, HRB 736403 +{{if eq .Lang "de"}}Geschäftsführer{{else}}Managing directors{{end}}: Benjamin Bönisch {{if eq .Lang "de"}}und{{else}}and{{end}} Sharang Deepak Parnerkar{{end}}