diff --git a/routers/api/v1/activitypub/person.go b/routers/api/v1/activitypub/person.go index 4068dfcf6f..268e5092b1 100644 --- a/routers/api/v1/activitypub/person.go +++ b/routers/api/v1/activitypub/person.go @@ -269,8 +269,7 @@ func PersonFollowing(ctx *context.APIContext) { following.TotalItems = uint(len(users)) for _, user := range users { - // TODO: handle non-Federated users - person := ap.PersonNew(ap.IRI(user.Website)) + person := ap.PersonNew(ap.IRI(user.GetIRI())) err := following.OrderedItems.Append(person) if err != nil { ctx.ServerError("OrderedItems.Append", err) @@ -310,8 +309,7 @@ func PersonFollowers(ctx *context.APIContext) { followers.TotalItems = uint(len(users)) for _, user := range users { - // TODO: handle non-Federated users - person := ap.PersonNew(ap.IRI(user.Website)) + person := ap.PersonNew(ap.IRI(user.GetIRI())) err := followers.OrderedItems.Append(person) if err != nil { ctx.ServerError("OrderedItems.Append", err) @@ -355,8 +353,7 @@ func PersonLiked(ctx *context.APIContext) { liked.TotalItems = uint(count) for _, repo := range repos { - // TODO: Handle remote starred repos - repo := forgefed.RepositoryNew(ap.IRI(setting.AppURL + "api/v1/activitypub/repo/" + repo.OwnerName + "/" + repo.Name)) + repo := forgefed.RepositoryNew(ap.IRI(repo.GetIRI())) err := liked.OrderedItems.Append(repo) if err != nil { ctx.ServerError("OrderedItems.Append", err) diff --git a/routers/api/v1/activitypub/repo.go b/routers/api/v1/activitypub/repo.go index df1e5e2335..9a5c0f6a30 100644 --- a/routers/api/v1/activitypub/repo.go +++ b/routers/api/v1/activitypub/repo.go @@ -12,7 +12,6 @@ import ( "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/forgefed" "code.gitea.io/gitea/modules/log" - "code.gitea.io/gitea/modules/setting" ap "github.com/go-ap/activitypub" ) @@ -49,7 +48,7 @@ func Repo(ctx *context.APIContext) { return } - repo.AttributedTo = ap.IRI(setting.AppURL + "api/v1/activitypub/user/" + ctx.ContextUser.Name) + repo.AttributedTo = ap.IRI(ctx.Repo.Owner.GetIRI()) repo.Summary = ap.NaturalLanguageValuesNew() err = repo.Summary.Set("en", ap.Content(ctx.Repo.Repository.Description)) diff --git a/services/activitypub/activities.go b/services/activitypub/activities.go index 4aad43e8d7..a232886a00 100644 --- a/services/activitypub/activities.go +++ b/services/activitypub/activities.go @@ -6,7 +6,6 @@ package activitypub import ( user_model "code.gitea.io/gitea/models/user" - "code.gitea.io/gitea/modules/setting" ap "github.com/go-ap/activitypub" ) @@ -16,7 +15,7 @@ func Follow(actorUser, followUser *user_model.User) *ap.Follow { object := ap.PersonNew(ap.IRI(followUser.LoginName)) follow := ap.FollowNew("", object) follow.Type = ap.FollowType - follow.Actor = ap.PersonNew(ap.IRI(setting.AppURL + "api/v1/activitypub/user/" + actorUser.Name)) + follow.Actor = ap.PersonNew(ap.IRI(actorUser.GetIRI())) follow.To = ap.ItemCollection{ap.Item(ap.IRI(followUser.LoginName + "/inbox"))} return follow } @@ -25,7 +24,7 @@ func Follow(actorUser, followUser *user_model.User) *ap.Follow { func Unfollow(actorUser, followUser *user_model.User) *ap.Undo { object := ap.PersonNew(ap.IRI(followUser.LoginName)) follow := ap.FollowNew("", object) - follow.Actor = ap.PersonNew(ap.IRI(setting.AppURL + "api/v1/activitypub/user/" + actorUser.Name)) + follow.Actor = ap.PersonNew(ap.IRI(actorUser.GetIRI())) unfollow := ap.UndoNew("", follow) unfollow.Type = ap.UndoType unfollow.To = ap.ItemCollection{ap.Item(ap.IRI(followUser.LoginName + "/inbox"))} diff --git a/services/activitypub/transport.go b/services/activitypub/transport.go index 2a48750242..38005052e0 100644 --- a/services/activitypub/transport.go +++ b/services/activitypub/transport.go @@ -51,7 +51,7 @@ func Send(user *user_model.User, activity *ap.Activity) error { } for _, to := range activity.To { - client, _ := NewClient(user, setting.AppURL+"api/v1/activitypub/user/"+user.Name+"#main-key") + client, _ := NewClient(user, user.GetIRI()+"#main-key") resp, _ := client.Post(binary, to.GetLink().String()) respBody, _ := io.ReadAll(io.LimitReader(resp.Body, setting.Federation.MaxSize)) log.Trace("Response from sending activity", string(respBody))