Add ToDos from code review
This commit is contained in:
parent
34c511ae98
commit
8300d3fbde
2 changed files with 6 additions and 6 deletions
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
type Validatable interface { // ToDo: What is the right package for this interface?
|
||||
validate_is_not_nil() error
|
||||
validate_is_not_nil() error // ToDo: We may want an IsValid and a ThrowIfInvalid method, that collects errors and throws them at RepositoryInbox level
|
||||
validate_is_not_empty() error
|
||||
Validate() error
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ type ActorID struct {
|
|||
port string // optional
|
||||
}
|
||||
|
||||
// ToDo: validate_is_not_empty maybe not as an extra method
|
||||
func (a ActorID) validate_is_not_empty(str string, field string) error {
|
||||
|
||||
if str == "" {
|
||||
|
@ -61,7 +62,7 @@ func (a ActorID) Validate() error {
|
|||
return err
|
||||
}
|
||||
|
||||
if !strings.Contains(a.path, "api/v1/activitypub/user-id") {
|
||||
if !strings.Contains(a.path, "api/v1/activitypub/user-id") { // This needs to happen in dependence to the star source type.
|
||||
return fmt.Errorf("the Path to the API was invalid: %v", a.path)
|
||||
}
|
||||
|
||||
|
@ -80,8 +81,8 @@ func ParseActorID(actor string) (ActorID, error) {
|
|||
pathWithUserID := strings.Split(u.Path, "/")
|
||||
userId := pathWithUserID[len(pathWithUserID)-1]
|
||||
|
||||
return ActorID{
|
||||
schema: u.Scheme,
|
||||
return ActorID{ // ToDo: maybe keep original input to validate against (maybe extra method)
|
||||
schema: u.Scheme, // ToDo: Add source type field
|
||||
userId: userId,
|
||||
host: u.Host,
|
||||
path: u.Path,
|
||||
|
|
|
@ -86,9 +86,8 @@ func RepositoryInbox(ctx *context.APIContext) {
|
|||
log.Info("RepositoryInbox: Activity.Actor %v", opt.Actor)
|
||||
|
||||
// assume actor is: "actor": "https://codeberg.org/api/v1/activitypub/user-id/12345" - NB: This might be actually the ID? Maybe check vocabulary.
|
||||
// TODO: validate input in front of parsing.
|
||||
// parse actor
|
||||
actor, err := activitypub.ParseActorID(opt.Actor.GetID().String())
|
||||
actor, err := activitypub.ParseActorID(opt.Actor.GetID().String()) // ToDo: somehow extract source from star activity
|
||||
|
||||
// Is the actor IRI well formed?
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue