fixes mail notifications
This commit is contained in:
@@ -160,23 +160,23 @@ func ProcessActivity(e *core.RequestEvent) error {
|
||||
|
||||
switch activity.Type {
|
||||
case pub.FollowType:
|
||||
ProcessFollowActivity(e.App, actor, activity)
|
||||
err = ProcessFollowActivity(e.App, actor, activity)
|
||||
case pub.AcceptType:
|
||||
ProcessAcceptActivity(e.App, actor, activity)
|
||||
err = ProcessAcceptActivity(e.App, actor, activity)
|
||||
case pub.UndoType:
|
||||
ProcessUndoActivity(e.App, actor, activity)
|
||||
err = ProcessUndoActivity(e.App, actor, activity)
|
||||
case pub.UpdateType:
|
||||
fallthrough
|
||||
case pub.CreateType:
|
||||
ProcessCreateOrUpdateActivity(e.App, actor, activity)
|
||||
err = ProcessCreateOrUpdateActivity(e.App, actor, activity)
|
||||
case pub.DeleteType:
|
||||
ProcessDeleteActivity(e.App, actor, activity)
|
||||
err = ProcessDeleteActivity(e.App, actor, activity)
|
||||
case pub.AnnounceType:
|
||||
ProcessAnnounceActivity(e.App, actor, activity)
|
||||
err = ProcessAnnounceActivity(e.App, actor, activity)
|
||||
case pub.LikeType:
|
||||
ProcessLikeActivity(e.App, actor, activity)
|
||||
err = ProcessLikeActivity(e.App, actor, activity)
|
||||
}
|
||||
return e.JSON(http.StatusOK, nil)
|
||||
return e.JSON(http.StatusOK, err)
|
||||
}
|
||||
|
||||
func verifySignature(app core.App, req *http.Request, publicKeyPem string) (bool, error) {
|
||||
|
||||
@@ -99,7 +99,7 @@ func GetActorByIRI(app core.App, actor *core.Record, iri string, includeFollows
|
||||
func iriFromHandle(domain string, username string) (string, error) {
|
||||
client := &http.Client{}
|
||||
|
||||
webfingerURL := fmt.Sprintf("http://%s/.well-known/webfinger?resource=acct:%s@%s", domain, username, domain)
|
||||
webfingerURL := fmt.Sprintf("https://%s/.well-known/webfinger?resource=acct:%s@%s", domain, username, domain)
|
||||
resp, err := client.Get(webfingerURL)
|
||||
if err != nil || resp.StatusCode != http.StatusOK {
|
||||
return "", fmt.Errorf("webfinger request failed: %v", err)
|
||||
@@ -140,12 +140,12 @@ func assembleActor(actor *core.Record, dbActor *core.Record, app core.App, inclu
|
||||
dbActor.Set("icon", fmt.Sprintf("%s/api/v1/files/users/%s/%s", origin, user.Id, user.GetString("avatar")))
|
||||
}
|
||||
dbActor.Set("summary", settings.GetString("bio"))
|
||||
followerCount, err := app.CountRecords("follows", dbx.NewExp("followee={:user}", dbx.Params{"user": dbActor.Id}))
|
||||
followerCount, err := app.CountRecords("follows", dbx.NewExp("followee={:user} AND status='accepted'", dbx.Params{"user": dbActor.Id}))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dbActor.Set("followerCount", followerCount)
|
||||
followingCount, err := app.CountRecords("follows", dbx.NewExp("follower={:user}", dbx.Params{"user": dbActor.Id}))
|
||||
followingCount, err := app.CountRecords("follows", dbx.NewExp("follower={:user} AND status='accepted'", dbx.Params{"user": dbActor.Id}))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
.button {
|
||||
display: inline-block;
|
||||
background-color: #242734;
|
||||
color: #ffffff;
|
||||
color: #ffffff !important;
|
||||
padding: 10px 20px;
|
||||
border-radius: 5px;
|
||||
text-decoration: none;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user