aboutsummaryrefslogtreecommitdiff
path: root/routers
diff options
context:
space:
mode:
authorAnthony Wang2023-03-15 20:14:00 +0000
committerAnthony Wang2023-03-15 20:14:00 +0000
commit3b547c695eb78908d8b01d46944604c07b41dbd1 (patch)
treece7b738dffb64dff1c7c4c4f235f41f93c76c64d /routers
parentdbc3eb7fa071307e623fde961bfdff0894856948 (diff)
Fix some annoying segfaults
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/activitypub/create.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/routers/api/v1/activitypub/create.go b/routers/api/v1/activitypub/create.go
index 591671c0c..4b0ba5edf 100644
--- a/routers/api/v1/activitypub/create.go
+++ b/routers/api/v1/activitypub/create.go
@@ -119,7 +119,7 @@ func createPersonFromIRI(ctx context.Context, personIRI ap.IRI) error {
if err != nil {
return err
}
- return ap.On(object, func(p *ap.Person) error {
+ return ap.OnActor(object, func(p *ap.Person) error {
return createPerson(ctx, p)
})
}
@@ -128,16 +128,21 @@ func createPersonFromIRI(ctx context.Context, personIRI ap.IRI) error {
func createRepository(ctx context.Context, repository *forgefed.Repository) error {
user, err := user_model.GetUserByIRI(ctx, repository.AttributedTo.GetLink().String())
if user_model.IsErrUserNotExist(err) {
+ // TODO: This should probably return the created user too
err := createPersonFromIRI(ctx, repository.AttributedTo.GetLink())
if err != nil {
return err
}
+ user, err = user_model.GetUserByIRI(ctx, repository.AttributedTo.GetLink().String())
+ if err != nil {
+ return err
+ }
} else if err != nil {
return err
}
// Check if repo exists
- _, err = repo_model.GetRepositoryByOwnerAndName(ctx, user.Name, repository.Name.String())
+ _, err = repo_model.GetRepositoryByIRI(ctx, repository.GetLink().String())
if !repo_model.IsErrRepoNotExist(err) {
return err
}