From 9ccad50b055191088684cd594e45557450406f36 Mon Sep 17 00:00:00 2001
From: Michael Jerger <michael.jerger@meissa-gmbh.de>
Date: Fri, 22 Mar 2024 07:52:03 +0100
Subject: [PATCH] review

---
 models/forgefed/activity.go   | 1 +
 models/repo/repo.go           | 2 ++
 modules/validation/helpers.go | 1 +
 routers/api/v1/user/star.go   | 3 +++
 4 files changed, 7 insertions(+)

diff --git a/models/forgefed/activity.go b/models/forgefed/activity.go
index b0d17b9a9c..409a074142 100644
--- a/models/forgefed/activity.go
+++ b/models/forgefed/activity.go
@@ -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()
diff --git a/models/repo/repo.go b/models/repo/repo.go
index 2cd3b51b6e..da10b315f1 100644
--- a/models/repo/repo.go
+++ b/models/repo/repo.go
@@ -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))
 }
diff --git a/modules/validation/helpers.go b/modules/validation/helpers.go
index 6069714410..9780399747 100644
--- a/modules/validation/helpers.go
+++ b/modules/validation/helpers.go
@@ -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
 }
diff --git a/routers/api/v1/user/star.go b/routers/api/v1/user/star.go
index a07407ffc3..42df6d9a90 100644
--- a/routers/api/v1/user/star.go
+++ b/routers/api/v1/user/star.go
@@ -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)