Anthony Wang 2022-07-25 15:45:15 -05:00
parent 30b431da49
commit 38a687c60e
No known key found for this signature in database
GPG Key ID: BC96B00AEC5F2D76
6 changed files with 13 additions and 13 deletions

View File

@ -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)

View File

@ -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, "@") {

View File

@ -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]

View File

@ -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))
}

View File

@ -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
}

View File

@ -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
}