1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2025-10-10 19:32:02 +00:00
forgejo/routers/web/repo/issue_suggestions.go

35 lines
854 B
Go
Raw Normal View History

2025-06-06 01:25:07 +03:00
// Copyright 2024 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package repo
import (
"net/http"
"forgejo.org/models/unit"
"forgejo.org/modules/optional"
"forgejo.org/services/context"
issue_service "forgejo.org/services/issue"
)
// IssueSuggestions returns a list of issue suggestions
func IssueSuggestions(ctx *context.Context) {
canReadIssues := ctx.Repo.CanRead(unit.TypeIssues)
canReadPulls := ctx.Repo.CanRead(unit.TypePullRequests)
var isPull optional.Option[bool]
if canReadPulls && !canReadIssues {
isPull = optional.Some(true)
} else if canReadIssues && !canReadPulls {
isPull = optional.Some(false)
}
2025-06-07 21:27:15 +03:00
suggestions, err := issue_service.GetSuggestions(ctx, ctx.Repo.Repository, isPull)
2025-06-06 01:25:07 +03:00
if err != nil {
2025-06-07 21:27:15 +03:00
ctx.ServerError("GetSuggestions", err)
2025-06-06 01:25:07 +03:00
return
}
ctx.JSON(http.StatusOK, suggestions)
}