Replace GetID() with GetLink()
See https://lists.sr.ht/~mariusor/activitypub-go/%3CNXRUnlucUSX8FL9I57dimPx4dpMKz01JDjKXqeHC8V9Z7pSTnjoZyV8ukearYJOq4IDogmpDLoEK-ScPDKs_egPnFGcAAO4XqHbj2rTUm-E%3D%40proton.me%3E for more detailspull/20391/head
parent
30b431da49
commit
38a687c60e
|
@ -42,10 +42,10 @@ func TestActivityPubPerson(t *testing.T) {
|
|||
|
||||
assert.Equal(t, ap.PersonType, person.Type)
|
||||
assert.Equal(t, username, person.PreferredUsername.String())
|
||||
keyID := person.GetID().String()
|
||||
keyID := person.GetLink().String()
|
||||
assert.Regexp(t, fmt.Sprintf("activitypub/user/%s$", username), keyID)
|
||||
assert.Regexp(t, fmt.Sprintf("activitypub/user/%s/outbox$", username), person.Outbox.GetID().String())
|
||||
assert.Regexp(t, fmt.Sprintf("activitypub/user/%s/inbox$", username), person.Inbox.GetID().String())
|
||||
assert.Regexp(t, fmt.Sprintf("activitypub/user/%s/outbox$", username), person.Outbox.GetLink().String())
|
||||
assert.Regexp(t, fmt.Sprintf("activitypub/user/%s/inbox$", username), person.Inbox.GetLink().String())
|
||||
|
||||
pubKey := person.PublicKey
|
||||
assert.NotNil(t, pubKey)
|
||||
|
|
|
@ -16,14 +16,14 @@ import (
|
|||
// Process a Follow activity
|
||||
func Follow(ctx context.Context, follow ap.Follow) error {
|
||||
// Actor is the user performing the follow
|
||||
actorIRI := follow.Actor.GetID()
|
||||
actorIRI := follow.Actor.GetLink()
|
||||
actorUser, err := personIRIToUser(ctx, actorIRI)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Object is the user being followed
|
||||
objectIRI := follow.Object.GetID()
|
||||
objectIRI := follow.Object.GetLink()
|
||||
objectUser, err := personIRIToUser(ctx, objectIRI)
|
||||
// Must be a local user
|
||||
if err != nil || strings.Contains(objectUser.Name, "@") {
|
||||
|
@ -47,14 +47,14 @@ func Follow(ctx context.Context, follow ap.Follow) error {
|
|||
func Unfollow(ctx context.Context, unfollow ap.Undo) error {
|
||||
follow := unfollow.Object.(*ap.Follow)
|
||||
// Actor is the user performing the undo follow
|
||||
actorIRI := follow.Actor.GetID()
|
||||
actorIRI := follow.Actor.GetLink()
|
||||
actorUser, err := personIRIToUser(ctx, actorIRI)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Object is the user being unfollowed
|
||||
objectIRI := follow.Object.GetID()
|
||||
objectIRI := follow.Object.GetLink()
|
||||
objectUser, err := personIRIToUser(ctx, objectIRI)
|
||||
// Must be a local user
|
||||
if err != nil || strings.Contains(objectUser.Name, "@") {
|
||||
|
|
|
@ -52,7 +52,7 @@ func ForkFromCreate(ctx context.Context, repository forgefed.Repository) error {
|
|||
// https://gitea.com/Ta180m/gitea/issues/7
|
||||
|
||||
// Create the fork
|
||||
repoIRI := repository.GetID()
|
||||
repoIRI := repository.GetLink()
|
||||
repoIRISplit := strings.Split(repoIRI.String(), "/")
|
||||
instance := repoIRISplit[2]
|
||||
username := repoIRISplit[7]
|
||||
|
|
|
@ -52,7 +52,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")
|
||||
resp, _ := client.Post(binary, to.GetID().String())
|
||||
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))
|
||||
}
|
||||
|
|
|
@ -116,11 +116,11 @@ func PersonInbox(ctx *context.APIContext) {
|
|||
|
||||
// Make sure keyID matches the user doing the activity
|
||||
_, keyID, _ := getKeyID(ctx.Req)
|
||||
if activity.Actor != nil && !strings.HasPrefix(keyID, activity.Actor.GetID().String()) {
|
||||
if activity.Actor != nil && !strings.HasPrefix(keyID, activity.Actor.GetLink().String()) {
|
||||
ctx.ServerError("Actor does not match HTTP signature keyID", nil)
|
||||
return
|
||||
}
|
||||
if activity.AttributedTo != nil && !strings.HasPrefix(keyID, activity.AttributedTo.GetID().String()) {
|
||||
if activity.AttributedTo != nil && !strings.HasPrefix(keyID, activity.AttributedTo.GetLink().String()) {
|
||||
ctx.ServerError("AttributedTo does not match HTTP signature keyID", nil)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -105,11 +105,11 @@ func RepoInbox(ctx *context.APIContext) {
|
|||
|
||||
// Make sure keyID matches the user doing the activity
|
||||
_, keyID, _ := getKeyID(ctx.Req)
|
||||
if activity.Actor != nil && !strings.HasPrefix(keyID, activity.Actor.GetID().String()) {
|
||||
if activity.Actor != nil && !strings.HasPrefix(keyID, activity.Actor.GetLink().String()) {
|
||||
ctx.ServerError("Actor does not match HTTP signature keyID", nil)
|
||||
return
|
||||
}
|
||||
if activity.AttributedTo != nil && !strings.HasPrefix(keyID, activity.AttributedTo.GetID().String()) {
|
||||
if activity.AttributedTo != nil && !strings.HasPrefix(keyID, activity.AttributedTo.GetLink().String()) {
|
||||
ctx.ServerError("AttributedTo does not match HTTP signature keyID", nil)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue