Use GetIRI() function instead of manually constructing IRI
parent
439f6754ac
commit
a8be3ece4b
|
@ -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)
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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"))}
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue