diff --git a/modules/activitypub/authorize_interaction.go b/modules/activitypub/authorize_interaction.go index 1803aaf9d2..e7decc54f6 100644 --- a/modules/activitypub/authorize_interaction.go +++ b/modules/activitypub/authorize_interaction.go @@ -64,7 +64,7 @@ func AuthorizeInteraction(ctx *context.Context) { ctx.ServerError("repositoryIRIToName", err) return } - ctx.Redirect(username+"/"+reponame) + ctx.Redirect(username + "/" + reponame) } ctx.Status(http.StatusOK) diff --git a/modules/activitypub/iri.go b/modules/activitypub/iri.go index 592c269136..e0ccfd8b03 100644 --- a/modules/activitypub/iri.go +++ b/modules/activitypub/iri.go @@ -83,9 +83,11 @@ func repositoryIRIToOwnerIRI(repoIRI ap.IRI) (ap.IRI, error) { r := repoIRI.String() rSplit := strings.Split(r, "/") if len(rSplit) < 5 { - return "", errors.New("Not a Repository actor IRI") + return "", errors.New("not a Repository actor IRI") } + username := rSplit[len(rSplit)-2] reponame := rSplit[len(rSplit)-1] - return ap.IRI(strings.TrimSuffix(r, "repo/"+username+"/"+reponame)+"user/"+username), nil + ownerIRI := ap.IRI(strings.TrimSuffix(r, "repo/"+username+"/"+reponame) + "user/" + username) + return ownerIRI, nil } diff --git a/modules/activitypub/repo.go b/modules/activitypub/repo.go index 2a716f7059..b7e88742bf 100644 --- a/modules/activitypub/repo.go +++ b/modules/activitypub/repo.go @@ -8,8 +8,8 @@ import ( "context" "code.gitea.io/gitea/models" - repo_service "code.gitea.io/gitea/services/repository" "code.gitea.io/gitea/modules/forgefed" + repo_service "code.gitea.io/gitea/services/repository" ) // Create a new federated repo from a Repository object diff --git a/modules/forgefed/forgefed.go b/modules/forgefed/forgefed.go index 9d6ec7cadc..a6229a1d56 100644 --- a/modules/forgefed/forgefed.go +++ b/modules/forgefed/forgefed.go @@ -31,7 +31,7 @@ func GetItemByType(typ ap.ActivityVocabularyType) (ap.Item, error) { // JSONUnmarshalerFn is the type of the function that will load the data from a fastjson.Value into an Item // that the go-ap/activitypub package doesn't know about. -func JSONUnmarshalerFn(typ ap.ActivityVocabularyType, val *fastjson.Value, i ap.Item) error { +func JSONUnmarshalerFn(typ ap.ActivityVocabularyType, val *fastjson.Value, i ap.Item) error { switch typ { case CommitType: return OnCommit(i, func(c *Commit) error {