1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2025-08-01 17:38:33 +00:00

unify logging & minor improvements

This commit is contained in:
Michael Jerger 2023-12-15 14:45:20 +01:00
parent 42854c9003
commit e1d7db178c
3 changed files with 83 additions and 72 deletions

View file

@ -31,9 +31,10 @@ type RepositoryId struct {
}
func NewPersonId(uri string, source string) (PersonId, error) {
if !validation.IsValidExternalURL(uri) {
return PersonId{}, fmt.Errorf("uri %s is not a valid external url", uri)
}
// TODO: remove after test
//if !validation.IsValidExternalURL(uri) {
// return PersonId{}, fmt.Errorf("uri %s is not a valid external url", uri)
//}
validatedUri, _ := url.Parse(uri)
pathWithActorID := strings.Split(validatedUri.Path, "/")
@ -99,11 +100,21 @@ func (id ActorId) AsUri() string {
return result
}
func (id ActorId) AsWebfinger() string {
func (id PersonId) AsWebfinger() string {
result := fmt.Sprintf("@%s@%s", strings.ToLower(id.Id), strings.ToLower(id.Host))
return result
}
func (id PersonId) AsLoginName() string {
result := fmt.Sprintf("%s%s", strings.ToLower(id.Id), id.HostSuffix())
return result
}
func (id PersonId) HostSuffix() string {
result := fmt.Sprintf("-%s", strings.ToLower(id.Host))
return result
}
/*
Validate collects error strings in a slice and returns this
*/