fixes mail notifications

This commit is contained in:
Christian Beutel
2025-06-27 11:51:23 +02:00
parent 277b435c65
commit 7b57252f7f
7 changed files with 22 additions and 17 deletions

View File

@@ -19,7 +19,7 @@ type EmailData struct {
var notificationTemplates = map[NotificationType]string{
TrailShare: "{{.Author}} has shared a trail with you: {{.trail}}.",
ListShare: "{{.Author}} has shared a list with you: {{.list}}.",
NewFollower: "Good news! You have a new follower: {{.Author}}.",
NewFollower: "Good news! You have a new follower: {{.follower}}.",
TrailComment: "{{.Author}} commented on your trail '{{.trail_name}}': '{{.comment}}'.",
SummitLogCreate: "{{.Author}} created a summit log on your trail '{{.trail_name}}'.",
TrailLike: "{{.Author}} liked your trail '{{.trail_name}}'.",
@@ -59,7 +59,7 @@ func GenerateHTML(appUrl string, recipientName string, authorName string, notifi
}
html, err := registry.LoadFiles(
"db/templates/mail/notification.html",
"templates/mail/notification.html",
).Render(content)
if err != nil {

View File

@@ -92,11 +92,15 @@ func SendNotification(app core.App, notification Notification, recipient *core.R
if err != nil {
return err
}
recipientUser, err := app.FindRecordById("users", recipientActor.GetString("user"))
if err != nil {
return err
}
authorActor, err := app.FindRecordById("activitypub_actors", notification.Author)
if err != nil {
return err
}
html, err := GenerateHTML(app.Settings().Meta.AppURL, recipientActor.GetString("preferred_username"), authorActor.GetString("preferred_username"), notification.Type, notification.Metadata)
html, err := GenerateHTML(app.Settings().Meta.AppURL, recipientActor.GetString("username"), authorActor.GetString("username"), notification.Type, notification.Metadata)
if err != nil {
return err
}
@@ -106,7 +110,7 @@ func SendNotification(app core.App, notification Notification, recipient *core.R
Address: app.Settings().Meta.SenderAddress,
Name: app.Settings().Meta.SenderName,
},
To: []mail.Address{{Address: recipientActor.Email()}},
To: []mail.Address{{Address: recipientUser.Email()}},
Subject: "wanderer - New Notification",
HTML: html,
}