mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-25 14:35:40 +00:00
review
This commit is contained in:
parent
7316108d56
commit
9ccad50b05
|
@ -19,6 +19,7 @@ type ForgeLike struct {
|
||||||
ap.Activity
|
ap.Activity
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Use explicit values instead of ctx !!
|
||||||
func NewForgeLike(ctx *context.APIContext) (ForgeLike, error) {
|
func NewForgeLike(ctx *context.APIContext) (ForgeLike, error) {
|
||||||
result := ForgeLike{}
|
result := ForgeLike{}
|
||||||
actorIRI := ctx.Repo.Owner.APAPIURL()
|
actorIRI := ctx.Repo.Owner.APAPIURL()
|
||||||
|
|
|
@ -347,6 +347,8 @@ func (repo *Repository) APIURL() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// APAPIURL returns the activitypub repository API URL
|
// APAPIURL returns the activitypub repository API URL
|
||||||
|
// TODO: At least camel case?
|
||||||
|
// TODO: Mv federation related stuff to federated_repo
|
||||||
func (repo *Repository) APAPIURL() string {
|
func (repo *Repository) APAPIURL() string {
|
||||||
return setting.AppURL + "api/v1/activitypub/repository-id/" + url.PathEscape(string(repo.ID))
|
return setting.AppURL + "api/v1/activitypub/repository-id/" + url.PathEscape(string(repo.ID))
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,6 +157,7 @@ func IsValidFederatedRepoURLList(urls string) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: use validateable/ValidateMaxLen instead !!
|
||||||
func IsOfValidLength(str string) bool {
|
func IsOfValidLength(str string) bool {
|
||||||
return len(str) <= 2048
|
return len(str) <= 2048
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
// Copyright 2016 The Gogs Authors. All rights reserved.
|
// Copyright 2016 The Gogs Authors. All rights reserved.
|
||||||
// Copyright 2020 The Gitea Authors.
|
// Copyright 2020 The Gitea Authors.
|
||||||
|
// Copyright 2024 The forgejo Authors.
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package user
|
package user
|
||||||
|
@ -164,6 +165,7 @@ func Star(ctx *context.APIContext) {
|
||||||
ctx.Error(http.StatusInternalServerError, "StarRepo", err)
|
ctx.Error(http.StatusInternalServerError, "StarRepo", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// TODO: move this code to repo.federated_repository
|
||||||
if setting.Federation.Enabled {
|
if setting.Federation.Enabled {
|
||||||
|
|
||||||
likeActivity, err := forgefed.NewForgeLike(ctx)
|
likeActivity, err := forgefed.NewForgeLike(ctx)
|
||||||
|
@ -183,6 +185,7 @@ func Star(ctx *context.APIContext) {
|
||||||
ctx.Error(http.StatusInternalServerError, "StarRepo", err)
|
ctx.Error(http.StatusInternalServerError, "StarRepo", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// TODO: set timeouts for outgoing request in oder to mitigate DOS by slow lories
|
||||||
// ToDo: Change this to the standalone table of FederatedRepos
|
// ToDo: Change this to the standalone table of FederatedRepos
|
||||||
for _, target := range strings.Split(ctx.Repo.Repository.FederationRepos, ";") {
|
for _, target := range strings.Split(ctx.Repo.Repository.FederationRepos, ";") {
|
||||||
apclient.Post([]byte(json), target)
|
apclient.Post([]byte(json), target)
|
||||||
|
|
Loading…
Reference in a new issue