mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-25 06:25:31 +00:00
adjust to ugly linting
This commit is contained in:
parent
1e40b814a1
commit
e704e5adcc
|
@ -18,7 +18,7 @@ type Validateables interface {
|
|||
}
|
||||
|
||||
type ActorID struct {
|
||||
Id string
|
||||
ID string
|
||||
Source string
|
||||
Schema string
|
||||
Path string
|
||||
|
@ -46,7 +46,7 @@ func newActorID(validatedURI *url.URL, source string) (ActorID, error) {
|
|||
id := pathWithActorID[length-1]
|
||||
|
||||
result := ActorID{}
|
||||
result.Id = id
|
||||
result.ID = id
|
||||
result.Source = source
|
||||
result.Schema = validatedURI.Scheme
|
||||
result.Host = validatedURI.Hostname()
|
||||
|
@ -86,7 +86,6 @@ func NewPersonID(uri string, source string) (PersonID, error) {
|
|||
}
|
||||
|
||||
func NewRepositoryID(uri string, source string) (RepositoryID, error) {
|
||||
|
||||
if !validation.IsAPIURL(uri) {
|
||||
return RepositoryID{}, fmt.Errorf("uri %s is not a valid repo url on this host %s", uri, setting.AppURL+"api")
|
||||
}
|
||||
|
@ -113,20 +112,20 @@ func NewRepositoryID(uri string, source string) (RepositoryID, error) {
|
|||
func (id ActorID) AsURI() string {
|
||||
var result string
|
||||
if id.Port == "" {
|
||||
result = fmt.Sprintf("%s://%s/%s/%s", id.Schema, id.Host, id.Path, id.Id)
|
||||
result = fmt.Sprintf("%s://%s/%s/%s", id.Schema, id.Host, id.Path, id.ID)
|
||||
} else {
|
||||
result = fmt.Sprintf("%s://%s:%s/%s/%s", id.Schema, id.Host, id.Port, id.Path, id.Id)
|
||||
result = fmt.Sprintf("%s://%s:%s/%s/%s", id.Schema, id.Host, id.Port, id.Path, id.ID)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func (id PersonID) AsWebfinger() string {
|
||||
result := fmt.Sprintf("@%s@%s", strings.ToLower(id.Id), strings.ToLower(id.Host))
|
||||
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())
|
||||
result := fmt.Sprintf("%s%s", strings.ToLower(id.ID), id.HostSuffix())
|
||||
return result
|
||||
}
|
||||
|
||||
|
@ -138,7 +137,7 @@ func (id PersonID) HostSuffix() string {
|
|||
// Validate collects error strings in a slice and returns this
|
||||
func (id ActorID) Validate() []string {
|
||||
var result []string
|
||||
result = append(result, validation.ValidateNotEmpty(id.Id, "userId")...)
|
||||
result = append(result, validation.ValidateNotEmpty(id.ID, "userId")...)
|
||||
result = append(result, validation.ValidateNotEmpty(id.Source, "source")...)
|
||||
result = append(result, validation.ValidateNotEmpty(id.Schema, "schema")...)
|
||||
result = append(result, validation.ValidateNotEmpty(id.Path, "path")...)
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
|
||||
func TestNewPersonId(t *testing.T) {
|
||||
expected := PersonID{}
|
||||
expected.Id = "1"
|
||||
expected.ID = "1"
|
||||
expected.Source = "forgejo"
|
||||
expected.Schema = "https"
|
||||
expected.Path = "api/v1/activitypub/user-id"
|
||||
|
@ -24,7 +24,7 @@ func TestNewPersonId(t *testing.T) {
|
|||
}
|
||||
|
||||
expected = PersonID{}
|
||||
expected.Id = "1"
|
||||
expected.ID = "1"
|
||||
expected.Source = "forgejo"
|
||||
expected.Schema = "https"
|
||||
expected.Path = "api/v1/activitypub/user-id"
|
||||
|
@ -40,7 +40,7 @@ func TestNewPersonId(t *testing.T) {
|
|||
func TestNewRepositoryId(t *testing.T) {
|
||||
setting.AppURL = "http://localhost:3000/"
|
||||
expected := RepositoryID{}
|
||||
expected.Id = "1"
|
||||
expected.ID = "1"
|
||||
expected.Source = "forgejo"
|
||||
expected.Schema = "http"
|
||||
expected.Path = "api/activitypub/repository-id"
|
||||
|
@ -66,7 +66,7 @@ func TestActorIdValidation(t *testing.T) {
|
|||
}
|
||||
|
||||
sut = ActorID{}
|
||||
sut.Id = "1"
|
||||
sut.ID = "1"
|
||||
sut.Source = "forgejox"
|
||||
sut.Schema = "https"
|
||||
sut.Path = "api/v1/activitypub/user-id"
|
||||
|
@ -78,7 +78,7 @@ func TestActorIdValidation(t *testing.T) {
|
|||
}
|
||||
|
||||
sut = ActorID{}
|
||||
sut.Id = "1"
|
||||
sut.ID = "1"
|
||||
sut.Source = "forgejo"
|
||||
sut.Schema = "https"
|
||||
sut.Path = "api/v1/activitypub/user-id"
|
||||
|
@ -92,7 +92,7 @@ func TestActorIdValidation(t *testing.T) {
|
|||
|
||||
func TestPersonIdValidation(t *testing.T) {
|
||||
sut := PersonID{}
|
||||
sut.Id = "1"
|
||||
sut.ID = "1"
|
||||
sut.Source = "forgejo"
|
||||
sut.Schema = "https"
|
||||
sut.Path = "path"
|
||||
|
|
|
@ -102,7 +102,7 @@ func RepositoryInbox(ctx *context.APIContext) {
|
|||
ctx.ServerError("Validate objectId", err)
|
||||
return
|
||||
}
|
||||
if objectID.Id != fmt.Sprint(repository.ID) {
|
||||
if objectID.ID != fmt.Sprint(repository.ID) {
|
||||
ctx.ServerError("Validate objectId", err)
|
||||
return
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ func createUserFromAP(ctx *context.APIContext, personID forgefed.PersonID) (*use
|
|||
|
||||
// validate response; ToDo: Should we widen the restrictions here?
|
||||
if response.StatusCode != 200 {
|
||||
err = fmt.Errorf("got non 200 status code for id: %v", personID.Id)
|
||||
err = fmt.Errorf("got non 200 status code for id: %v", personID.ID)
|
||||
return &user_model.User{}, err
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue