mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-13 05:11:20 +01:00
Add get functions for userId and HostAndPort
This commit is contained in:
parent
92c089a4e2
commit
91baf2be32
1 changed files with 21 additions and 0 deletions
|
@ -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 {
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue