diff --git a/db/federation/activity.go b/db/federation/activity.go index e32669ed..9cbd29b6 100644 --- a/db/federation/activity.go +++ b/db/federation/activity.go @@ -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) { diff --git a/db/federation/actor.go b/db/federation/actor.go index 6138ce37..aed47492 100644 --- a/db/federation/actor.go +++ b/db/federation/actor.go @@ -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 } diff --git a/db/templates/mail/notification.html b/db/templates/mail/notification.html index 6a1e84f4..7d01cab8 100644 --- a/db/templates/mail/notification.html +++ b/db/templates/mail/notification.html @@ -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; diff --git a/db/util/email_templates.go b/db/util/email_templates.go index d33fc0c5..fc467ee2 100644 --- a/db/util/email_templates.go +++ b/db/util/email_templates.go @@ -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 { diff --git a/db/util/notification.go b/db/util/notification.go index 1a52bcad..e1b0e2d8 100644 --- a/db/util/notification.go +++ b/db/util/notification.go @@ -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, } diff --git a/web/src/css/components.css b/web/src/css/components.css index b8e5568a..b7b70871 100644 --- a/web/src/css/components.css +++ b/web/src/css/components.css @@ -127,6 +127,6 @@ } .mention { - @apply bg-blue-100 dark:bg-slate-700 rounded-md; + @apply bg-blue-100 dark:bg-slate-700 rounded-md text-sm; padding: 0.1rem 0.3rem; } \ No newline at end of file diff --git a/web/src/routes/api/v1/activitypub/user/[handle]/+server.ts b/web/src/routes/api/v1/activitypub/user/[handle]/+server.ts index 6fb8852a..bc8460b2 100644 --- a/web/src/routes/api/v1/activitypub/user/[handle]/+server.ts +++ b/web/src/routes/api/v1/activitypub/user/[handle]/+server.ts @@ -29,6 +29,7 @@ export async function GET(event: RequestEvent) { const r: APRoot = { "@context": [ "https://www.w3.org/ns/activitystreams", + "https://w3id.org/security/v1", ], id: id, type: "Person",