Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-25 11:16:11 +01:00
This commit is contained in:
Michael Jerger 2024-03-22 07:52:03 +01:00
parent 7316108d56
commit 9ccad50b05
4 changed files with 7 additions and 0 deletions

View file

@ -19,6 +19,7 @@ type ForgeLike struct {
ap.Activity
}
// TODO: Use explicit values instead of ctx !!
func NewForgeLike(ctx *context.APIContext) (ForgeLike, error) {
result := ForgeLike{}
actorIRI := ctx.Repo.Owner.APAPIURL()

View file

@ -347,6 +347,8 @@ func (repo *Repository) APIURL() string {
}
// 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 {
return setting.AppURL + "api/v1/activitypub/repository-id/" + url.PathEscape(string(repo.ID))
}

View file

@ -157,6 +157,7 @@ func IsValidFederatedRepoURLList(urls string) bool {
return true
}
// TODO: use validateable/ValidateMaxLen instead !!
func IsOfValidLength(str string) bool {
return len(str) <= 2048
}

View file

@ -1,5 +1,6 @@
// Copyright 2016 The Gogs Authors. All rights reserved.
// Copyright 2020 The Gitea Authors.
// Copyright 2024 The forgejo Authors.
// SPDX-License-Identifier: MIT
package user
@ -164,6 +165,7 @@ func Star(ctx *context.APIContext) {
ctx.Error(http.StatusInternalServerError, "StarRepo", err)
return
}
// TODO: move this code to repo.federated_repository
if setting.Federation.Enabled {
likeActivity, err := forgefed.NewForgeLike(ctx)
@ -183,6 +185,7 @@ func Star(ctx *context.APIContext) {
ctx.Error(http.StatusInternalServerError, "StarRepo", err)
return
}
// TODO: set timeouts for outgoing request in oder to mitigate DOS by slow lories
// ToDo: Change this to the standalone table of FederatedRepos
for _, target := range strings.Split(ctx.Repo.Repository.FederationRepos, ";") {
apclient.Post([]byte(json), target)