From fde8de4f906b90d766f66d925409134c69ff8877 Mon Sep 17 00:00:00 2001 From: erik Date: Wed, 29 Nov 2023 13:26:35 +0100 Subject: [PATCH] Rename to ParseActorIDFromStarActivity --- models/activitypub/actor.go | 2 +- models/activitypub/actor_test.go | 6 +++--- routers/api/v1/activitypub/repository.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/models/activitypub/actor.go b/models/activitypub/actor.go index 37619bddde..53db5a2c81 100644 --- a/models/activitypub/actor.go +++ b/models/activitypub/actor.go @@ -98,7 +98,7 @@ func (a ActorID) GetHostAndPort() string { return a.host } -func ParseActorFromStarActivity(star *forgefed.Star) (ActorID, error) { +func ParseActorIDFromStarActivity(star *forgefed.Star) (ActorID, error) { u, err := url.Parse(star.Actor.GetID().String()) // check if userID IRI is well formed url diff --git a/models/activitypub/actor_test.go b/models/activitypub/actor_test.go index 37b57f25ab..6dffb8b270 100644 --- a/models/activitypub/actor_test.go +++ b/models/activitypub/actor_test.go @@ -32,7 +32,7 @@ func TestActorParserEmpty(t *testing.T) { item := emptyMockStar want := ActorID{} - got, _ := ParseActorFromStarActivity(item) + got, _ := ParseActorIDFromStarActivity(item) if got != want { t.Errorf("ParseActorID returned non empty actor id for empty input.") @@ -50,7 +50,7 @@ func TestActorParserValid(t *testing.T) { port: "", } - got, _ := ParseActorFromStarActivity(item) + got, _ := ParseActorIDFromStarActivity(item) if got != want { t.Errorf("\nParseActorID did not return want: %v\n but %v", want, got) @@ -75,7 +75,7 @@ func TestValidateValid(t *testing.T) { func TestValidateInvalid(t *testing.T) { item := emptyMockStar - actor, _ := ParseActorFromStarActivity(item) + actor, _ := ParseActorIDFromStarActivity(item) if valid, _ := actor.IsValid(); valid { t.Errorf("Actor was valid with invalid input.") diff --git a/routers/api/v1/activitypub/repository.go b/routers/api/v1/activitypub/repository.go index 492c7454aa..b2f42ca9bd 100644 --- a/routers/api/v1/activitypub/repository.go +++ b/routers/api/v1/activitypub/repository.go @@ -79,7 +79,7 @@ func RepositoryInbox(ctx *context.APIContext) { // assume actor is: "actor": "https://codeberg.org/api/v1/activitypub/user-id/12345" - NB: This might be actually the ID? Maybe check vocabulary. // parse actor - actor, err := activitypub.ParseActorFromStarActivity(opt) + actor, err := activitypub.ParseActorIDFromStarActivity(opt) // Is the actor IRI well formed? if err != nil {