1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-11-24 08:57:03 -05:00

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

View file

@ -3,6 +3,7 @@ package activitypub
import (
"fmt"
"net/url"
"strconv"
"strings"
)
@ -29,6 +30,26 @@ func (a ActorID) validate_is_not_empty(str string, field string) error {
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
func (a ActorID) Validate() error {