From c8a8e1ec91cf2414c3890c7cf6fa5acc284c4f65 Mon Sep 17 00:00:00 2001 From: Anthony Wang Date: Wed, 20 Jul 2022 18:16:40 -0500 Subject: [PATCH] Check err in Follow() to avoid crash and don't check FederatedUserNew error --- modules/activitypub/follow.go | 3 +-- modules/activitypub/iri.go | 6 +----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/modules/activitypub/follow.go b/modules/activitypub/follow.go index 18c58bf4ce..58cdcf059b 100644 --- a/modules/activitypub/follow.go +++ b/modules/activitypub/follow.go @@ -28,7 +28,7 @@ func Follow(ctx context.Context, follow ap.Follow) { objectIRI := follow.Object.GetID() objectUser, err := personIRIToUser(ctx, objectIRI) // Must be a local user - if strings.Contains(objectUser.Name, "@") || err != nil { + if err != nil || strings.Contains(objectUser.Name, "@") { log.Warn("Couldn't find object user for follow", err) return } @@ -44,7 +44,6 @@ func Follow(ctx context.Context, follow ap.Follow) { } // Process a Undo follow activity -// I haven't tried this yet so hopefully it works func Unfollow(ctx context.Context, unfollow ap.Undo) { follow := unfollow.Object.(*ap.Follow) // Actor is the user performing the undo follow diff --git a/modules/activitypub/iri.go b/modules/activitypub/iri.go index 1733c0ab33..92fc0add5b 100644 --- a/modules/activitypub/iri.go +++ b/modules/activitypub/iri.go @@ -47,11 +47,7 @@ func personIRIToUser(ctx context.Context, personIRI ap.IRI) (*user_model.User, e return user, err } - err = FederatedUserNew(personIRI) - if err != nil { - return nil, err - } - + FederatedUserNew(personIRI) return user_model.GetUserByName(ctx, name) }