mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-22 05:36:16 +00:00
Make the source an argument to the parser
This commit is contained in:
parent
2fb893843b
commit
4f25e5057a
|
@ -6,7 +6,6 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"code.gitea.io/gitea/modules/forgefed"
|
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -20,7 +19,7 @@ type Validatable interface { // ToDo: What is the right package for this interfa
|
||||||
|
|
||||||
type ActorID struct {
|
type ActorID struct {
|
||||||
userId string
|
userId string
|
||||||
source forgefed.SourceType
|
source string
|
||||||
schema string
|
schema string
|
||||||
path string
|
path string
|
||||||
host string
|
host string
|
||||||
|
@ -126,8 +125,8 @@ func removeEmptyStrings(ls []string) []string {
|
||||||
return rs
|
return rs
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseActorIDFromStarActivity(star *forgefed.Star) (ActorID, error) {
|
func ParseActorID(unvalidatedIRI, source string) (ActorID, error) {
|
||||||
u, err := url.Parse(star.Actor.GetID().String())
|
u, err := url.Parse(unvalidatedIRI)
|
||||||
|
|
||||||
// check if userID IRI is well formed url
|
// check if userID IRI is well formed url
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -150,7 +149,7 @@ func ParseActorIDFromStarActivity(star *forgefed.Star) (ActorID, error) {
|
||||||
|
|
||||||
return ActorID{ // ToDo: maybe keep original input to validate against (maybe extra method)
|
return ActorID{ // ToDo: maybe keep original input to validate against (maybe extra method)
|
||||||
userId: userId,
|
userId: userId,
|
||||||
source: star.Source,
|
source: source,
|
||||||
schema: u.Scheme,
|
schema: u.Scheme,
|
||||||
host: u.Hostname(), // u.Host returns hostname:port
|
host: u.Hostname(), // u.Host returns hostname:port
|
||||||
path: pathWithoutUserID,
|
path: pathWithoutUserID,
|
||||||
|
|
Loading…
Reference in a new issue