From 071b47b8d0a710712e6c106decd33bf7f0f42813 Mon Sep 17 00:00:00 2001 From: erik Date: Tue, 19 Dec 2023 12:26:55 +0100 Subject: [PATCH] Catch edge case: remote user does not exist on remote repo --- routers/api/v1/activitypub/repository.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/routers/api/v1/activitypub/repository.go b/routers/api/v1/activitypub/repository.go index 89fb46b40a..2a13510f3c 100644 --- a/routers/api/v1/activitypub/repository.go +++ b/routers/api/v1/activitypub/repository.go @@ -120,7 +120,7 @@ func RepositoryInbox(ctx *context.APIContext) { { user, err = createUserFromAP(ctx, actorId) if err != nil { - ctx.ServerError("Searching for user failed", err) + ctx.ServerError("Creating user failed", err) return } log.Info("RepositoryInbox: created user from ap: %v", user) @@ -195,7 +195,11 @@ func createUserFromAP(ctx *context.APIContext, personId forgefed.PersonId) (*use } log.Info("RepositoryInbox: got body: %v", string(body)) person := ap.Person{} - err = person.UnmarshalJSON(body) + if strings.Contains(string(body), "user does not exist") { + err = fmt.Errorf("the requested user id did not exist on the remote server: %v", personId.Id) + } else { + err = person.UnmarshalJSON(body) + } if err != nil { return &user_model.User{}, err }