From 3d2b5115ad1c904ee727f7d9cd62469fdf3884cd Mon Sep 17 00:00:00 2001 From: erik Date: Wed, 22 Nov 2023 15:25:43 +0100 Subject: [PATCH] Implement and use Validatable interface --- models/activitypub/actor.go | 6 +++++- routers/api/v1/activitypub/repository.go | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/models/activitypub/actor.go b/models/activitypub/actor.go index b6ba240e20..94acacdfdd 100644 --- a/models/activitypub/actor.go +++ b/models/activitypub/actor.go @@ -6,6 +6,10 @@ import ( "strings" ) +type Validatable interface { + Validate() error +} + type ActorID struct { schema string userId string @@ -15,7 +19,7 @@ type ActorID struct { } // TODO: Align validation-api to example from dda-devops-build -func (a ActorID) ValidateActorID() error { +func (a ActorID) Validate() error { if a.schema == "" || a.host == "" { return fmt.Errorf("the actor ID was not valid: Invalid Schema or Host") diff --git a/routers/api/v1/activitypub/repository.go b/routers/api/v1/activitypub/repository.go index b6fb98d1ae..b70a95c0b7 100644 --- a/routers/api/v1/activitypub/repository.go +++ b/routers/api/v1/activitypub/repository.go @@ -96,7 +96,7 @@ func RepositoryInbox(ctx *context.APIContext) { } // Is the ActorData Struct valid? - err = actor.ValidateActorID() + err = actor.Validate() if err != nil { panic(err)