This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

appview/notify/email: cap at 10 notifs

This still marks the unshown ones as "emailed" so we don't send them in
the next digest tick.

Signed-off-by: Anirudh Oppiliappan <anirudh@tangled.org>

author
Anirudh Oppiliappan
committer
Tangled
date (Jul 24, 2026, 7:46 PM +0300) commit 877b7747 parent c2584c9f change-id kvrnopzn
+40 -16
+40 -16
appview/notify/email/dispatcher.go
··· 24 24 {{range .Groups}}- {{wrap 70 " " .Header}}{{if .EntityRef}} 25 25 {{wrap 70 " " .EntityRef}}{{end}} 26 26 {{.URL}} 27 - {{end}} 28 - --- 27 + {{end}}{{if .HasMore}} 28 + View more notifications: {{.NotificationsURL}} 29 + {{end}}--- 29 30 Manage notifications: {{.SettingsURL}} 30 31 ` 31 32 ··· 73 74 </tr> 74 75 {{end}} 75 76 </table> 77 + {{if .HasMore}} 78 + <p style="font-size:14px;padding:16px 0 0 0;margin:0;"> 79 + <a href="{{.NotificationsURL}}" style="color:#111827;text-decoration:underline;font-weight:400;">View more notifications</a> 80 + </p> 81 + {{end}} 76 82 <table align="center" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation"> 77 83 <tbody> 78 84 <tr> ··· 188 194 } 189 195 return b.String() 190 196 } 197 + 198 + // digestMaxGroups caps how many notifications are itemized in a digest email; 199 + // beyond this a "View more" link points to the notifications page. 200 + const digestMaxGroups = 10 191 201 192 202 type digestData struct { 193 - RecipientHandle string 194 - Count int 195 - Groups []digestGroup 196 - SettingsURL string 197 - AssetsURL string 203 + RecipientHandle string 204 + Count int 205 + Groups []digestGroup 206 + HasMore bool 207 + NotificationsURL string 208 + SettingsURL string 209 + AssetsURL string 198 210 } 199 211 200 212 // Dispatcher polls the notifications table and sends digest emails. ··· 326 338 } 327 339 328 340 func (d *Dispatcher) renderDigest(ctx context.Context, recipientHandle string, notifs []*models.NotificationWithEntity) (subject, text, html string, err error) { 329 - groups := make([]digestGroup, 0, len(notifs)) 341 + count := len(notifs) 330 342 331 - for _, n := range notifs { 343 + shown := notifs 344 + if len(shown) > digestMaxGroups { 345 + shown = shown[:digestMaxGroups] 346 + } 347 + 348 + groups := make([]digestGroup, 0, len(shown)) 349 + 350 + for _, n := range shown { 332 351 actorHandle := n.ActorDid 333 352 if id, err2 := d.resolver.ResolveIdent(ctx, n.ActorDid); err2 == nil && !id.Handle.IsInvalidHandle() { 334 353 actorHandle = id.Handle.String() ··· 354 373 }) 355 374 } 356 375 357 - count := len(notifs) 358 376 data := digestData{ 359 - RecipientHandle: recipientHandle, 360 - Count: count, 361 - Groups: groups, 362 - SettingsURL: d.baseURL + "/settings/notifications", 363 - AssetsURL: d.assetsURL, 377 + RecipientHandle: recipientHandle, 378 + Count: count, 379 + Groups: groups, 380 + HasMore: count > digestMaxGroups, 381 + NotificationsURL: d.baseURL + "/notifications", 382 + SettingsURL: d.baseURL + "/settings/notifications", 383 + AssetsURL: d.assetsURL, 364 384 } 365 385 366 - subject = fmt.Sprintf("[%s] %d notification(s)", recipientHandle, count) 386 + if count > digestMaxGroups { 387 + subject = fmt.Sprintf("[%s] %d+ notifications", recipientHandle, digestMaxGroups) 388 + } else { 389 + subject = fmt.Sprintf("[%s] %d notification(s)", recipientHandle, count) 390 + } 367 391 368 392 var textBuf bytes.Buffer 369 393 if err = d.textTmpl.Execute(&textBuf, data); err != nil {