From 891fbe229e72dcefd8739ea0183703398596011b Mon Sep 17 00:00:00 2001 From: Anirudh Oppiliappan Date: Wed, 26 Aug 2026 13:05:36 +0000 Subject: [PATCH] deliberi/emailtemplate: extract shared email shell from digest Signed-off-by: Anirudh Oppiliappan --- deliberi/digest.go | 110 ++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------- deliberi/emailtemplate/template.go | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 file(s) changed, 85 insertion(s)(+), 76 deletion(s)(-) diff --git a/deliberi/digest.go b/deliberi/digest.go --- a/deliberi/digest.go +++ b/deliberi/digest.go @@ -13,6 +13,7 @@ "github.com/bluesky-social/indigo/atproto/syntax" "tangled.org/core/deliberi/config" deldb "tangled.org/core/deliberi/db" + "tangled.org/core/deliberi/emailtemplate" "tangled.org/core/deliberi/mailer" "tangled.org/core/deliberi/models" "tangled.org/core/idresolver" @@ -31,80 +32,39 @@ Manage notifications: {{.SettingsURL}} ` -const digestHTMLTmpl = ` - - - - -Tangled notifications - - - - - -
- - - - - - +const digestBodyHTMLTmpl = `

Hi {{.RecipientHandle}},

+

+ You have {{.Count}} new notification{{if gt .Count 1}}s{{end}}: +

+
-
- Tangled -
-

Hi {{.RecipientHandle}},

-

- You have {{.Count}} new notification{{if gt .Count 1}}s{{end}}: -

- - {{range .Groups}} - - - - {{end}} -
- - - - - - -
- - -

{{.HeaderHTML}}

- {{if .EntityRef}}

{{.EntityRef}}

{{end}} -
-
-
- {{if .HasMore}} -

- View more notifications -

- {{end}} - - - - - - -
-

- Manage notification settings -

-

Tangled Labs Oy. © 2026 All rights reserved.

-

- tangled.org -

-
-
+ {{range .Groups}} + + - - + + + + {{end}}
+ + + + + +
+ + +

{{.HeaderHTML}}

+ {{if .EntityRef}}

{{.EntityRef}}

{{end}} +
-
- -` +{{if .HasMore}} +

+ View more notifications +

+{{end}} +

+ Manage notification settings +

` const digestMaxGroups = 10 @@ -123,7 +83,6 @@ HasMore bool NotificationsURL string SettingsURL string - AssetsURL string } func notifHeader(n *models.Notification, actor, repo string) string { @@ -225,7 +184,7 @@ batchWait: batchWait, interval: interval, textTmpl: gotemplate.Must(gotemplate.New("digest-text").Funcs(gotemplate.FuncMap{"wrap": wordwrap}).Parse(digestTextTmpl)), - htmlTmpl: template.Must(template.New("digest-html").Parse(digestHTMLTmpl)), + htmlTmpl: template.Must(template.New("digest-body").Parse(digestBodyHTMLTmpl)), } } @@ -347,7 +306,6 @@ HasMore: count > digestMaxGroups, NotificationsURL: d.baseURL + "/notifications", SettingsURL: d.baseURL + "/settings/notifications", - AssetsURL: d.assetsURL, } if count > digestMaxGroups { @@ -366,6 +324,6 @@ if err = d.htmlTmpl.Execute(&htmlBuf, data); err != nil { return } - html = htmlBuf.String() + html = emailtemplate.Shell("Tangled notifications", htmlBuf.String(), d.baseURL) return } diff --git a/deliberi/emailtemplate/template.go b/deliberi/emailtemplate/template.go new file mode 100644 --- /dev/null +++ b/deliberi/emailtemplate/template.go @@ -0,0 +1,51 @@ +// Package emailtemplate is the branded HTML shell shared by every deliberi email. +package emailtemplate + +import "strings" + +// Shell wraps title and bodyHTML in the Tangled-branded email document. The +// logo is served by the web app at /logos/dolly.png (web/static/logos). +func Shell(title, bodyHTML, baseURL string) string { + return ` + + + + +` + title + ` + + + + + + + + +
+ + + + + + +
+
+ Tangled +
+` + bodyHTML + ` + + + + + + +
+

Tangled Labs Oy. © 2026 All rights reserved.

+

+ tangled.org +

+
+
+
+ +` +} -- tangled.sh