mirror of
1
Fork 0

Add get functions for userId and HostAndPort

This commit is contained in:
erik 2023-11-23 17:03:24 +01:00 committed by Michael Jerger
parent 92c089a4e2
commit 91baf2be32
1 changed files with 21 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package activitypub
import ( import (
"fmt" "fmt"
"net/url" "net/url"
"strconv"
"strings" "strings"
) )
@ -29,6 +30,26 @@ func (a ActorID) validate_is_not_empty(str string, field string) error {
return nil return nil
} }
func (a ActorID) GetUserId() int {
result, err := strconv.Atoi(a.userId)
if err != nil {
panic(err)
}
return result
}
// Returns the combination of host:port if port exists, host otherwise
func (a ActorID) GetHostAndPort() string {
if a.port != "" {
return strings.Join([]string{a.host, a.port}, ":")
}
return a.host
}
// TODO: Align validation-api to example from dda-devops-build // TODO: Align validation-api to example from dda-devops-build
func (a ActorID) Validate() error { func (a ActorID) Validate() error {