chore: tidy up uploading migration code (#12577)

- Validate and sanitize topics.
- Cap topics at 25 (limit used elsewhere, now unified constant).
- Add more details and rephrase common user-facing error messages.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/12577
This commit is contained in:
Gusted
2026-05-16 11:46:14 +02:00
committed by Gusted
parent f4450f5015
commit aae19e6c19
5 changed files with 123 additions and 100 deletions
+1 -1
View File
@@ -104,7 +104,7 @@ func UpdateTopics(ctx *context.APIContext) {
topicNames := form.Topics
validTopics, invalidTopics := repo_model.SanitizeAndValidateTopics(topicNames)
if len(validTopics) > 25 {
if len(validTopics) > repo_model.MaxTopicsPerRepo {
ctx.JSON(http.StatusUnprocessableEntity, map[string]any{
"invalidTopics": nil,
"message": "Exceeding maximum number of topics per repo",
+1 -1
View File
@@ -29,7 +29,7 @@ func TopicsPost(ctx *context.Context) {
validTopics, invalidTopics := repo_model.SanitizeAndValidateTopics(topics)
if len(validTopics) > 25 {
if len(validTopics) > repo_model.MaxTopicsPerRepo {
ctx.JSON(http.StatusUnprocessableEntity, map[string]any{
"invalidTopics": nil,
"message": ctx.Tr("repo.topic.count_prompt"),