Replace interface{} with any (#25686)

Result of running `perl -p -i -e 's#interface\{\}#any#g' **/*` and `make fmt`.

Basically the same [as golang did](2580d0e08d).
This commit is contained in:
silverwind 2023-07-04 20:36:08 +02:00 committed by GitHub
parent 00dbba7f42
commit 88f835192d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
233 changed files with 727 additions and 727 deletions

View file

@ -116,7 +116,7 @@ func getVariablesOfTask(ctx context.Context, task *actions_model.ActionTask) map
}
func generateTaskContext(t *actions_model.ActionTask) *structpb.Struct {
event := map[string]interface{}{}
event := map[string]any{}
_ = json.Unmarshal([]byte(t.Job.Run.EventPayload), &event)
// TriggerEvent is added in https://github.com/go-gitea/gitea/pull/25229
@ -136,7 +136,7 @@ func generateTaskContext(t *actions_model.ActionTask) *structpb.Struct {
refName := git.RefName(t.Job.Run.Ref)
taskContext, err := structpb.NewStruct(map[string]interface{}{
taskContext, err := structpb.NewStruct(map[string]any{
// standard contexts, see https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
"action": "", // string, The name of the action currently running, or the id of a step. GitHub removes special characters, and uses the name __run when the current step runs a script without an id. If you use the same action more than once in the same job, the name will include a suffix with the sequence number with underscore before it. For example, the first script you run will have the name __run, and the second script will be named __run_2. Similarly, the second invocation of actions/checkout will be actionscheckout2.
"action_path": "", // string, The path where an action is located. This property is only supported in composite actions. You can use this path to access files located in the same repository as the action.

View file

@ -24,7 +24,7 @@ import (
alpine_service "code.gitea.io/gitea/services/packages/alpine"
)
func apiError(ctx *context.Context, status int, obj interface{}) {
func apiError(ctx *context.Context, status int, obj any) {
helper.LogAndProcessError(ctx, status, obj, func(message string) {
ctx.PlainText(status, message)
})

View file

@ -33,7 +33,7 @@ type StatusMessage struct {
Message string `json:"detail"`
}
func apiError(ctx *context.Context, status int, obj interface{}) {
func apiError(ctx *context.Context, status int, obj any) {
helper.LogAndProcessError(ctx, status, obj, func(message string) {
ctx.JSON(status, StatusResponse{
OK: false,

View file

@ -24,7 +24,7 @@ import (
packages_service "code.gitea.io/gitea/services/packages"
)
func apiError(ctx *context.Context, status int, obj interface{}) {
func apiError(ctx *context.Context, status int, obj any) {
type Error struct {
ErrorMessages []string `json:"error_messages"`
}

View file

@ -26,7 +26,7 @@ import (
"github.com/hashicorp/go-version"
)
func apiError(ctx *context.Context, status int, obj interface{}) {
func apiError(ctx *context.Context, status int, obj any) {
helper.LogAndProcessError(ctx, status, obj, func(message string) {
type Error struct {
Status int `json:"status"`

View file

@ -47,7 +47,7 @@ var (
)
)
func jsonResponse(ctx *context.Context, status int, obj interface{}) {
func jsonResponse(ctx *context.Context, status int, obj any) {
// https://github.com/conan-io/conan/issues/6613
ctx.Resp.Header().Set("Content-Type", "application/json")
ctx.Status(status)
@ -56,7 +56,7 @@ func jsonResponse(ctx *context.Context, status int, obj interface{}) {
}
}
func apiError(ctx *context.Context, status int, obj interface{}) {
func apiError(ctx *context.Context, status int, obj any) {
helper.LogAndProcessError(ctx, status, obj, func(message string) {
jsonResponse(ctx, status, map[string]string{
"message": message,
@ -796,13 +796,13 @@ func listRevisionFiles(ctx *context.Context, fileKey string) {
return
}
files := make(map[string]interface{})
files := make(map[string]any)
for _, pf := range pfs {
files[pf.Name] = nil
}
type FileList struct {
Files map[string]interface{} `json:"files"`
Files map[string]any `json:"files"`
}
jsonResponse(ctx, http.StatusOK, &FileList{

View file

@ -24,7 +24,7 @@ import (
"github.com/dsnet/compress/bzip2"
)
func apiError(ctx *context.Context, status int, obj interface{}) {
func apiError(ctx *context.Context, status int, obj any) {
helper.LogAndProcessError(ctx, status, obj, func(message string) {
ctx.JSON(status, struct {
Reason string `json:"reason"`

View file

@ -75,7 +75,7 @@ func setResponseHeaders(resp http.ResponseWriter, h *containerHeaders) {
resp.WriteHeader(h.Status)
}
func jsonResponse(ctx *context.Context, status int, obj interface{}) {
func jsonResponse(ctx *context.Context, status int, obj any) {
setResponseHeaders(ctx.Resp, &containerHeaders{
Status: status,
ContentType: "application/json",

View file

@ -21,7 +21,7 @@ import (
packages_service "code.gitea.io/gitea/services/packages"
)
func apiError(ctx *context.Context, status int, obj interface{}) {
func apiError(ctx *context.Context, status int, obj any) {
helper.LogAndProcessError(ctx, status, obj, func(message string) {
ctx.PlainText(status, message)
})

View file

@ -23,7 +23,7 @@ import (
debian_service "code.gitea.io/gitea/services/packages/debian"
)
func apiError(ctx *context.Context, status int, obj interface{}) {
func apiError(ctx *context.Context, status int, obj any) {
helper.LogAndProcessError(ctx, status, obj, func(message string) {
ctx.PlainText(status, message)
})

View file

@ -22,7 +22,7 @@ var (
filenameRegex = packageNameRegex
)
func apiError(ctx *context.Context, status int, obj interface{}) {
func apiError(ctx *context.Context, status int, obj any) {
helper.LogAndProcessError(ctx, status, obj, func(message string) {
ctx.PlainText(status, message)
})

View file

@ -20,7 +20,7 @@ import (
packages_service "code.gitea.io/gitea/services/packages"
)
func apiError(ctx *context.Context, status int, obj interface{}) {
func apiError(ctx *context.Context, status int, obj any) {
helper.LogAndProcessError(ctx, status, obj, func(message string) {
ctx.PlainText(status, message)
})

View file

@ -26,7 +26,7 @@ import (
"gopkg.in/yaml.v3"
)
func apiError(ctx *context.Context, status int, obj interface{}) {
func apiError(ctx *context.Context, status int, obj any) {
helper.LogAndProcessError(ctx, status, obj, func(message string) {
type Error struct {
Error string `json:"error"`

View file

@ -17,7 +17,7 @@ import (
// LogAndProcessError logs an error and calls a custom callback with the processed error message.
// If the error is an InternalServerError the message is stripped if the user is not an admin.
func LogAndProcessError(ctx *context.Context, status int, obj interface{}, cb func(string)) {
func LogAndProcessError(ctx *context.Context, status int, obj any, cb func(string)) {
var message string
if err, ok := obj.(error); ok {
message = err.Error()

View file

@ -47,7 +47,7 @@ var (
illegalCharacters = regexp.MustCompile(`[\\/:"<>|?\*]`)
)
func apiError(ctx *context.Context, status int, obj interface{}) {
func apiError(ctx *context.Context, status int, obj any) {
helper.LogAndProcessError(ctx, status, obj, func(message string) {
ctx.PlainText(status, message)
})

View file

@ -30,7 +30,7 @@ import (
// errInvalidTagName indicates an invalid tag name
var errInvalidTagName = errors.New("The tag name is invalid")
func apiError(ctx *context.Context, status int, obj interface{}) {
func apiError(ctx *context.Context, status int, obj any) {
helper.LogAndProcessError(ctx, status, obj, func(message string) {
ctx.JSON(status, map[string]string{
"error": message,

View file

@ -25,7 +25,7 @@ import (
packages_service "code.gitea.io/gitea/services/packages"
)
func apiError(ctx *context.Context, status int, obj interface{}) {
func apiError(ctx *context.Context, status int, obj any) {
helper.LogAndProcessError(ctx, status, obj, func(message string) {
ctx.JSON(status, map[string]string{
"Message": message,
@ -33,7 +33,7 @@ func apiError(ctx *context.Context, status int, obj interface{}) {
})
}
func xmlResponse(ctx *context.Context, status int, obj interface{}) {
func xmlResponse(ctx *context.Context, status int, obj any) {
ctx.Resp.Header().Set("Content-Type", "application/atom+xml; charset=utf-8")
ctx.Resp.WriteHeader(status)
if _, err := ctx.Resp.Write([]byte(xml.Header)); err != nil {

View file

@ -25,7 +25,7 @@ import (
packages_service "code.gitea.io/gitea/services/packages"
)
func jsonResponse(ctx *context.Context, status int, obj interface{}) {
func jsonResponse(ctx *context.Context, status int, obj any) {
resp := ctx.Resp
resp.Header().Set("Content-Type", "application/vnd.pub.v2+json")
resp.WriteHeader(status)
@ -34,7 +34,7 @@ func jsonResponse(ctx *context.Context, status int, obj interface{}) {
}
}
func apiError(ctx *context.Context, status int, obj interface{}) {
func apiError(ctx *context.Context, status int, obj any) {
type Error struct {
Code string `json:"code"`
Message string `json:"message"`
@ -60,10 +60,10 @@ type packageVersions struct {
}
type versionMetadata struct {
Version string `json:"version"`
ArchiveURL string `json:"archive_url"`
Published time.Time `json:"published"`
Pubspec interface{} `json:"pubspec,omitempty"`
Version string `json:"version"`
ArchiveURL string `json:"archive_url"`
Published time.Time `json:"published"`
Pubspec any `json:"pubspec,omitempty"`
}
func packageDescriptorToMetadata(baseURL string, pd *packages_model.PackageDescriptor) *versionMetadata {

View file

@ -37,7 +37,7 @@ var versionMatcher = regexp.MustCompile(`\Av?` +
`(?:\+[a-z0-9]+(?:[-_\.][a-z0-9]+)*)?` + // local version
`\z`)
func apiError(ctx *context.Context, status int, obj interface{}) {
func apiError(ctx *context.Context, status int, obj any) {
helper.LogAndProcessError(ctx, status, obj, func(message string) {
ctx.PlainText(status, message)
})

View file

@ -25,7 +25,7 @@ import (
rpm_service "code.gitea.io/gitea/services/packages/rpm"
)
func apiError(ctx *context.Context, status int, obj interface{}) {
func apiError(ctx *context.Context, status int, obj any) {
helper.LogAndProcessError(ctx, status, obj, func(message string) {
ctx.PlainText(status, message)
})

View file

@ -21,7 +21,7 @@ import (
packages_service "code.gitea.io/gitea/services/packages"
)
func apiError(ctx *context.Context, status int, obj interface{}) {
func apiError(ctx *context.Context, status int, obj any) {
helper.LogAndProcessError(ctx, status, obj, func(message string) {
ctx.PlainText(status, message)
})
@ -65,9 +65,9 @@ func enumeratePackages(ctx *context.Context, filename string, pvs []*packages_mo
return
}
specs := make([]interface{}, 0, len(pds))
specs := make([]any, 0, len(pds))
for _, p := range pds {
specs = append(specs, []interface{}{
specs = append(specs, []any{
p.Package.Name,
&rubygems_module.RubyUserMarshal{
Name: "Gem::Version",
@ -129,7 +129,7 @@ func ServePackageSpecification(ctx *context.Context) {
// create a Ruby Gem::Specification object
spec := &rubygems_module.RubyUserDef{
Name: "Gem::Specification",
Value: []interface{}{
Value: []any{
"3.2.3", // @rubygems_version
4, // @specification_version,
pd.Package.Name,
@ -142,7 +142,7 @@ func ServePackageSpecification(ctx *context.Context) {
nil, // @required_ruby_version
nil, // @required_rubygems_version
metadata.Platform, // @original_platform
[]interface{}{}, // @dependencies
[]any{}, // @dependencies
nil, // rubyforge_project
"", // @email
metadata.Authors,

View file

@ -69,7 +69,7 @@ func setResponseHeaders(resp http.ResponseWriter, h *headers) {
}
// https://github.com/apple/swift-package-manager/blob/main/Documentation/Registry.md#33-error-handling
func apiError(ctx *context.Context, status int, obj interface{}) {
func apiError(ctx *context.Context, status int, obj any) {
// https://www.rfc-editor.org/rfc/rfc7807
type Problem struct {
Status int `json:"status"`

View file

@ -22,7 +22,7 @@ import (
"github.com/hashicorp/go-version"
)
func apiError(ctx *context.Context, status int, obj interface{}) {
func apiError(ctx *context.Context, status int, obj any) {
helper.LogAndProcessError(ctx, status, obj, func(message string) {
ctx.JSON(status, struct {
Errors []string `json:"errors"`

View file

@ -792,7 +792,7 @@ func SearchTeam(ctx *context.APIContext) {
teams, maxResults, err := organization.SearchTeam(opts)
if err != nil {
log.Error("SearchTeam failed: %v", err)
ctx.JSON(http.StatusInternalServerError, map[string]interface{}{
ctx.JSON(http.StatusInternalServerError, map[string]any{
"ok": false,
"error": "SearchTeam internal failure",
})
@ -807,7 +807,7 @@ func SearchTeam(ctx *context.APIContext) {
ctx.SetLinkHeader(int(maxResults), listOptions.PageSize)
ctx.SetTotalCountHeader(maxResults)
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"ok": true,
"data": apiTeams,
})

View file

@ -378,7 +378,7 @@ func Generate(ctx *context.APIContext) {
ctxUser, err = user_model.GetUserByName(ctx, form.Owner)
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.JSON(http.StatusNotFound, map[string]interface{}{
ctx.JSON(http.StatusNotFound, map[string]any{
"error": "request owner `" + form.Owner + "` does not exist",
})
return

View file

@ -63,7 +63,7 @@ func ListTopics(ctx *context.APIContext) {
}
ctx.SetTotalCountHeader(total)
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"topics": topicNames,
})
}
@ -101,7 +101,7 @@ func UpdateTopics(ctx *context.APIContext) {
validTopics, invalidTopics := repo_model.SanitizeAndValidateTopics(topicNames)
if len(validTopics) > 25 {
ctx.JSON(http.StatusUnprocessableEntity, map[string]interface{}{
ctx.JSON(http.StatusUnprocessableEntity, map[string]any{
"invalidTopics": nil,
"message": "Exceeding maximum number of topics per repo",
})
@ -109,7 +109,7 @@ func UpdateTopics(ctx *context.APIContext) {
}
if len(invalidTopics) > 0 {
ctx.JSON(http.StatusUnprocessableEntity, map[string]interface{}{
ctx.JSON(http.StatusUnprocessableEntity, map[string]any{
"invalidTopics": invalidTopics,
"message": "Topic names are invalid",
})
@ -158,7 +158,7 @@ func AddTopic(ctx *context.APIContext) {
topicName := strings.TrimSpace(strings.ToLower(ctx.Params(":topic")))
if !repo_model.ValidateTopic(topicName) {
ctx.JSON(http.StatusUnprocessableEntity, map[string]interface{}{
ctx.JSON(http.StatusUnprocessableEntity, map[string]any{
"invalidTopics": topicName,
"message": "Topic name is invalid",
})
@ -175,7 +175,7 @@ func AddTopic(ctx *context.APIContext) {
return
}
if count >= 25 {
ctx.JSON(http.StatusUnprocessableEntity, map[string]interface{}{
ctx.JSON(http.StatusUnprocessableEntity, map[string]any{
"message": "Exceeding maximum allowed topics per repo.",
})
return
@ -223,7 +223,7 @@ func DeleteTopic(ctx *context.APIContext) {
topicName := strings.TrimSpace(strings.ToLower(ctx.Params(":topic")))
if !repo_model.ValidateTopic(topicName) {
ctx.JSON(http.StatusUnprocessableEntity, map[string]interface{}{
ctx.JSON(http.StatusUnprocessableEntity, map[string]any{
"invalidTopics": topicName,
"message": "Topic name is invalid",
})
@ -289,7 +289,7 @@ func TopicSearch(ctx *context.APIContext) {
}
ctx.SetTotalCountHeader(total)
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"topics": topicResponses,
})
}

View file

@ -62,7 +62,7 @@ func Search(ctx *context.APIContext) {
ListOptions: listOptions,
})
if err != nil {
ctx.JSON(http.StatusInternalServerError, map[string]interface{}{
ctx.JSON(http.StatusInternalServerError, map[string]any{
"ok": false,
"error": err.Error(),
})
@ -72,7 +72,7 @@ func Search(ctx *context.APIContext) {
ctx.SetLinkHeader(int(maxResults), listOptions.PageSize)
ctx.SetTotalCountHeader(maxResults)
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"ok": true,
"data": convert.ToUsers(ctx, ctx.Doer, users),
})

View file

@ -49,7 +49,7 @@ func Processes(ctx *context.PrivateContext) {
}
if json {
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"TotalNumberOfGoroutines": goroutineCount,
"TotalNumberOfProcesses": processCount,
"Processes": processes,

View file

@ -60,7 +60,7 @@ func Authentications(ctx *context.Context) {
type dropdownItem struct {
Name string
Type interface{}
Type any
}
var (
@ -454,7 +454,7 @@ func DeleteAuthSource(ctx *context.Context) {
} else {
ctx.Flash.Error(fmt.Sprintf("auth_service.DeleteSource: %v", err))
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": setting.AppSubURL + "/admin/auths/" + url.PathEscape(ctx.Params(":authid")),
})
return
@ -462,7 +462,7 @@ func DeleteAuthSource(ctx *context.Context) {
log.Trace("Authentication deleted by admin(%s): %d", ctx.Doer.Name, source.ID)
ctx.Flash.Success(ctx.Tr("admin.auths.deletion_success"))
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": setting.AppSubURL + "/admin/auths",
})
}

View file

@ -207,7 +207,7 @@ func ChangeConfig(ctx *context.Context) {
return
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"version": version + 1,
})
}

View file

@ -26,8 +26,8 @@ func DefaultOrSystemWebhooks(ctx *context.Context) {
ctx.Data["PageIsAdminSystemHooks"] = true
ctx.Data["PageIsAdminDefaultHooks"] = true
def := make(map[string]interface{}, len(ctx.Data))
sys := make(map[string]interface{}, len(ctx.Data))
def := make(map[string]any, len(ctx.Data))
sys := make(map[string]any, len(ctx.Data))
for k, v := range ctx.Data {
def[k] = v
sys[k] = v
@ -67,7 +67,7 @@ func DeleteDefaultOrSystemWebhook(ctx *context.Context) {
ctx.Flash.Success(ctx.Tr("repo.settings.webhook_deletion_success"))
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": setting.AppSubURL + "/admin/hooks",
})
}

View file

@ -97,7 +97,7 @@ func DeletePackageVersion(ctx *context.Context) {
}
ctx.Flash.Success(ctx.Tr("packages.settings.delete.success"))
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": setting.AppSubURL + "/admin/packages?page=" + url.QueryEscape(ctx.FormString("page")) + "&q=" + url.QueryEscape(ctx.FormString("q")) + "&type=" + url.QueryEscape(ctx.FormString("type")),
})
}

View file

@ -58,7 +58,7 @@ func DeleteRepo(ctx *context.Context) {
log.Trace("Repository deleted: %s", repo.FullName())
ctx.Flash.Success(ctx.Tr("repo.settings.deletion_success"))
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": setting.AppSubURL + "/admin/repos?page=" + url.QueryEscape(ctx.FormString("page")) + "&sort=" + url.QueryEscape(ctx.FormString("sort")),
})
}

View file

@ -42,7 +42,7 @@ func Stacktrace(ctx *context.Context) {
func StacktraceCancel(ctx *context.Context) {
pid := ctx.Params("pid")
process.GetManager().Cancel(process.IDType(pid))
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": setting.AppSubURL + "/admin/monitor/stacktrace",
})
}

View file

@ -56,7 +56,7 @@ func Users(ctx *context.Context) {
sortType = explore.UserSearchDefaultAdminSort
ctx.SetFormString("sort", sortType)
}
ctx.PageData["adminUserListSearchForm"] = map[string]interface{}{
ctx.PageData["adminUserListSearchForm"] = map[string]any{
"StatusFilterMap": statusFilterMap,
"SortType": sortType,
}

View file

@ -78,7 +78,7 @@ func AutoSignIn(ctx *context.Context) (bool, error) {
isSucceed = true
if err := updateSession(ctx, nil, map[string]interface{}{
if err := updateSession(ctx, nil, map[string]any{
// Set session IDs
"uid": u.ID,
"uname": u.Name,
@ -255,7 +255,7 @@ func SignInPost(ctx *context.Context) {
return
}
updates := map[string]interface{}{
updates := map[string]any{
// User will need to use 2FA TOTP or WebAuthn, save data
"twofaUid": u.ID,
"twofaRemember": form.Remember,
@ -305,7 +305,7 @@ func handleSignInFull(ctx *context.Context, u *user_model.User, remember, obeyRe
"twofaUid",
"twofaRemember",
"linkAccount",
}, map[string]interface{}{
}, map[string]any{
"uid": u.ID,
"uname": u.Name,
}); err != nil {
@ -476,7 +476,7 @@ func SignUpPost(ctx *context.Context) {
// createAndHandleCreatedUser calls createUserInContext and
// then handleUserCreated.
func createAndHandleCreatedUser(ctx *context.Context, tpl base.TplName, form interface{}, u *user_model.User, overwrites *user_model.CreateUserOverwriteOptions, gothUser *goth.User, allowLink bool) bool {
func createAndHandleCreatedUser(ctx *context.Context, tpl base.TplName, form any, u *user_model.User, overwrites *user_model.CreateUserOverwriteOptions, gothUser *goth.User, allowLink bool) bool {
if !createUserInContext(ctx, tpl, form, u, overwrites, gothUser, allowLink) {
return false
}
@ -485,7 +485,7 @@ func createAndHandleCreatedUser(ctx *context.Context, tpl base.TplName, form int
// createUserInContext creates a user and handles errors within a given context.
// Optionally a template can be specified.
func createUserInContext(ctx *context.Context, tpl base.TplName, form interface{}, u *user_model.User, overwrites *user_model.CreateUserOverwriteOptions, gothUser *goth.User, allowLink bool) (ok bool) {
func createUserInContext(ctx *context.Context, tpl base.TplName, form any, u *user_model.User, overwrites *user_model.CreateUserOverwriteOptions, gothUser *goth.User, allowLink bool) (ok bool) {
if err := user_model.CreateUser(u, overwrites); err != nil {
if allowLink && (user_model.IsErrUserAlreadyExist(err) || user_model.IsErrEmailAlreadyUsed(err)) {
if setting.OAuth2Client.AccountLinking == setting.OAuth2AccountLinkingAuto {
@ -707,7 +707,7 @@ func handleAccountActivation(ctx *context.Context, user *user_model.User) {
log.Trace("User activated: %s", user.Name)
if err := updateSession(ctx, nil, map[string]interface{}{
if err := updateSession(ctx, nil, map[string]any{
"uid": user.ID,
"uname": user.Name,
}); err != nil {
@ -760,7 +760,7 @@ func ActivateEmail(ctx *context.Context) {
ctx.Redirect(setting.AppSubURL + "/user/settings/account")
}
func updateSession(ctx *context.Context, deletes []string, updates map[string]interface{}) error {
func updateSession(ctx *context.Context, deletes []string, updates map[string]any) error {
if _, err := session.RegenerateSession(ctx.Resp, ctx.Req); err != nil {
return fmt.Errorf("regenerate session: %w", err)
}

View file

@ -174,7 +174,7 @@ func linkAccount(ctx *context.Context, u *user_model.User, gothUser goth.User, r
return
}
if err := updateSession(ctx, nil, map[string]interface{}{
if err := updateSession(ctx, nil, map[string]any{
// User needs to use 2FA, save data and redirect to 2FA page.
"twofaUid": u.ID,
"twofaRemember": remember,

View file

@ -1008,13 +1008,13 @@ func SignInOAuthCallback(ctx *context.Context) {
handleOAuth2SignIn(ctx, authSource, u, gothUser)
}
func claimValueToStringSet(claimValue interface{}) container.Set[string] {
func claimValueToStringSet(claimValue any) container.Set[string] {
var groups []string
switch rawGroup := claimValue.(type) {
case []string:
groups = rawGroup
case []interface{}:
case []any:
for _, group := range rawGroup {
groups = append(groups, fmt.Sprintf("%s", group))
}
@ -1067,7 +1067,7 @@ func setUserAdminAndRestrictedFromGroupClaims(source *oauth2.Source, u *user_mod
}
func showLinkingLogin(ctx *context.Context, gothUser goth.User) {
if err := updateSession(ctx, nil, map[string]interface{}{
if err := updateSession(ctx, nil, map[string]any{
"linkAccountGothUser": gothUser,
}); err != nil {
ctx.ServerError("updateSession", err)
@ -1119,7 +1119,7 @@ func handleOAuth2SignIn(ctx *context.Context, source *auth.Source, u *user_model
// If this user is enrolled in 2FA and this source doesn't override it,
// we can't sign the user in just yet. Instead, redirect them to the 2FA authentication page.
if !needs2FA {
if err := updateSession(ctx, nil, map[string]interface{}{
if err := updateSession(ctx, nil, map[string]any{
"uid": u.ID,
"uname": u.Name,
}); err != nil {
@ -1189,7 +1189,7 @@ func handleOAuth2SignIn(ctx *context.Context, source *auth.Source, u *user_model
}
}
if err := updateSession(ctx, nil, map[string]interface{}{
if err := updateSession(ctx, nil, map[string]any{
// User needs to use 2FA, save data and redirect to 2FA page.
"twofaUid": u.ID,
"twofaRemember": false,

View file

@ -26,7 +26,7 @@ func createAndParseToken(t *testing.T, grant *auth.OAuth2Grant) *oauth2.OIDCToke
assert.Nil(t, terr)
assert.NotNil(t, response)
parsedToken, err := jwt.ParseWithClaims(response.IDToken, &oauth2.OIDCToken{}, func(token *jwt.Token) (interface{}, error) {
parsedToken, err := jwt.ParseWithClaims(response.IDToken, &oauth2.OIDCToken{}, func(token *jwt.Token) (any, error) {
assert.NotNil(t, token.Method)
assert.Equal(t, signingKey.SigningMethod().Alg(), token.Method.Alg())
return signingKey.VerifyKey(), nil

View file

@ -230,7 +230,7 @@ func signInOpenIDVerify(ctx *context.Context) {
if u != nil {
nickname = u.LowerName
}
if err := updateSession(ctx, nil, map[string]interface{}{
if err := updateSession(ctx, nil, map[string]any{
"openid_verified_uri": id,
"openid_determined_email": email,
"openid_determined_username": nickname,

View file

@ -35,7 +35,7 @@ func TopicSearch(ctx *context.Context) {
}
ctx.SetTotalCountHeader(total)
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"topics": topicResponses,
})
}

View file

@ -101,7 +101,7 @@ func MembersAction(ctx *context.Context) {
err = models.RemoveOrgUser(org.ID, uid)
if organization.IsErrLastOrgOwner(err) {
ctx.Flash.Error(ctx.Tr("form.last_org_owner"))
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": ctx.Org.OrgLink + "/members",
})
return
@ -110,12 +110,12 @@ func MembersAction(ctx *context.Context) {
err = models.RemoveOrgUser(org.ID, ctx.Doer.ID)
if err == nil {
ctx.Flash.Success(ctx.Tr("form.organization_leave_success", org.DisplayName()))
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": "", // keep the user stay on current page, in case they want to do other operations.
})
} else if organization.IsErrLastOrgOwner(err) {
ctx.Flash.Error(ctx.Tr("form.last_org_owner"))
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": ctx.Org.OrgLink + "/members",
})
} else {
@ -126,7 +126,7 @@ func MembersAction(ctx *context.Context) {
if err != nil {
log.Error("Action(%s): %v", ctx.Params(":action"), err)
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"ok": false,
"err": err.Error(),
})
@ -138,7 +138,7 @@ func MembersAction(ctx *context.Context) {
redirect = setting.AppSubURL + "/"
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": redirect,
})
}

View file

@ -90,7 +90,7 @@ func DeleteLabel(ctx *context.Context) {
ctx.Flash.Success(ctx.Tr("repo.issues.label_deletion_success"))
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": ctx.Org.OrgLink + "/settings/labels",
})
}

View file

@ -218,7 +218,7 @@ func DeleteProject(ctx *context.Context) {
ctx.Flash.Success(ctx.Tr("repo.projects.deletion_success"))
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": ctx.ContextUser.HomeLink() + "/-/projects",
})
}
@ -449,7 +449,7 @@ func UpdateIssueProject(ctx *context.Context) {
}
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"ok": true,
})
}
@ -497,7 +497,7 @@ func DeleteProjectBoard(ctx *context.Context) {
return
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"ok": true,
})
}
@ -526,7 +526,7 @@ func AddBoardToProjectPost(ctx *context.Context) {
return
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"ok": true,
})
}
@ -594,7 +594,7 @@ func EditProjectBoard(ctx *context.Context) {
return
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"ok": true,
})
}
@ -611,7 +611,7 @@ func SetDefaultProjectBoard(ctx *context.Context) {
return
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"ok": true,
})
}
@ -628,7 +628,7 @@ func UnsetDefaultProjectBoard(ctx *context.Context) {
return
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"ok": true,
})
}
@ -730,7 +730,7 @@ func MoveIssues(ctx *context.Context) {
return
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"ok": true,
})
}

View file

@ -224,7 +224,7 @@ func DeleteWebhook(ctx *context.Context) {
ctx.Flash.Success(ctx.Tr("repo.settings.webhook_deletion_success"))
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": ctx.Org.OrgLink + "/settings/hooks",
})
}

View file

@ -79,7 +79,7 @@ func TeamsAction(ctx *context.Context) {
ctx.Flash.Error(ctx.Tr("form.last_org_owner"))
} else {
log.Error("Action(%s): %v", ctx.Params(":action"), err)
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"ok": false,
"err": err.Error(),
})
@ -95,7 +95,7 @@ func TeamsAction(ctx *context.Context) {
redirect = setting.AppSubURL + "/"
}
ctx.JSON(http.StatusOK,
map[string]interface{}{
map[string]any{
"redirect": redirect,
})
return
@ -117,7 +117,7 @@ func TeamsAction(ctx *context.Context) {
ctx.Flash.Error(ctx.Tr("form.last_org_owner"))
} else {
log.Error("Action(%s): %v", ctx.Params(":action"), err)
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"ok": false,
"err": err.Error(),
})
@ -125,7 +125,7 @@ func TeamsAction(ctx *context.Context) {
}
}
ctx.JSON(http.StatusOK,
map[string]interface{}{
map[string]any{
"redirect": ctx.Org.OrgLink + "/teams/" + url.PathEscape(ctx.Org.Team.LowerName),
})
return
@ -199,7 +199,7 @@ func TeamsAction(ctx *context.Context) {
ctx.Flash.Error(ctx.Tr("form.last_org_owner"))
} else {
log.Error("Action(%s): %v", ctx.Params(":action"), err)
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"ok": false,
"err": err.Error(),
})
@ -256,7 +256,7 @@ func TeamsRepoAction(ctx *context.Context) {
}
if action == "addall" || action == "removeall" {
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": ctx.Org.OrgLink + "/teams/" + url.PathEscape(ctx.Org.Team.LowerName) + "/repositories",
})
return
@ -414,7 +414,7 @@ func SearchTeam(ctx *context.Context) {
teams, maxResults, err := org_model.SearchTeam(opts)
if err != nil {
log.Error("SearchTeam failed: %v", err)
ctx.JSON(http.StatusInternalServerError, map[string]interface{}{
ctx.JSON(http.StatusInternalServerError, map[string]any{
"ok": false,
"error": "SearchTeam internal failure",
})
@ -424,7 +424,7 @@ func SearchTeam(ctx *context.Context) {
apiTeams, err := convert.ToTeams(ctx, teams, false)
if err != nil {
log.Error("convert ToTeams failed: %v", err)
ctx.JSON(http.StatusInternalServerError, map[string]interface{}{
ctx.JSON(http.StatusInternalServerError, map[string]any{
"ok": false,
"error": "SearchTeam failed to get units",
})
@ -432,7 +432,7 @@ func SearchTeam(ctx *context.Context) {
}
ctx.SetTotalCountHeader(maxResults)
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"ok": true,
"data": apiTeams,
})
@ -530,7 +530,7 @@ func DeleteTeam(ctx *context.Context) {
ctx.Flash.Success(ctx.Tr("org.teams.delete_team_success"))
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": ctx.Org.OrgLink + "/teams",
})
}

View file

@ -162,7 +162,7 @@ func RestoreBranchPost(ctx *context.Context) {
}
func redirect(ctx *context.Context) {
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": ctx.Repo.RepoLink + "/branches?page=" + url.QueryEscape(ctx.FormString("page")),
})
}
@ -223,7 +223,7 @@ func CreateBranch(ctx *context.Context) {
if len(e.Message) == 0 {
ctx.Flash.Error(ctx.Tr("repo.editor.push_rejected_no_message"))
} else {
flashError, err := ctx.RenderToString(tplAlertDetails, map[string]interface{}{
flashError, err := ctx.RenderToString(tplAlertDetails, map[string]any{
"Message": ctx.Tr("repo.editor.push_rejected"),
"Summary": ctx.Tr("repo.editor.push_rejected_summary"),
"Details": utils.SanitizeFlashErrorString(e.Message),

View file

@ -344,7 +344,7 @@ func editFilePost(ctx *context.Context, form forms.EditRepoFileForm, isNewFile b
if len(errPushRej.Message) == 0 {
ctx.RenderWithErr(ctx.Tr("repo.editor.push_rejected_no_message"), tplEditFile, &form)
} else {
flashError, err := ctx.RenderToString(tplAlertDetails, map[string]interface{}{
flashError, err := ctx.RenderToString(tplAlertDetails, map[string]any{
"Message": ctx.Tr("repo.editor.push_rejected"),
"Summary": ctx.Tr("repo.editor.push_rejected_summary"),
"Details": utils.SanitizeFlashErrorString(errPushRej.Message),
@ -356,7 +356,7 @@ func editFilePost(ctx *context.Context, form forms.EditRepoFileForm, isNewFile b
ctx.RenderWithErr(flashError, tplEditFile, &form)
}
} else {
flashError, err := ctx.RenderToString(tplAlertDetails, map[string]interface{}{
flashError, err := ctx.RenderToString(tplAlertDetails, map[string]any{
"Message": ctx.Tr("repo.editor.fail_to_update_file", form.TreePath),
"Summary": ctx.Tr("repo.editor.fail_to_update_file_summary"),
"Details": utils.SanitizeFlashErrorString(err.Error()),
@ -543,7 +543,7 @@ func DeleteFilePost(ctx *context.Context) {
if len(errPushRej.Message) == 0 {
ctx.RenderWithErr(ctx.Tr("repo.editor.push_rejected_no_message"), tplDeleteFile, &form)
} else {
flashError, err := ctx.RenderToString(tplAlertDetails, map[string]interface{}{
flashError, err := ctx.RenderToString(tplAlertDetails, map[string]any{
"Message": ctx.Tr("repo.editor.push_rejected"),
"Summary": ctx.Tr("repo.editor.push_rejected_summary"),
"Details": utils.SanitizeFlashErrorString(errPushRej.Message),
@ -743,7 +743,7 @@ func UploadFilePost(ctx *context.Context) {
if len(errPushRej.Message) == 0 {
ctx.RenderWithErr(ctx.Tr("repo.editor.push_rejected_no_message"), tplUploadFile, &form)
} else {
flashError, err := ctx.RenderToString(tplAlertDetails, map[string]interface{}{
flashError, err := ctx.RenderToString(tplAlertDetails, map[string]any{
"Message": ctx.Tr("repo.editor.push_rejected"),
"Summary": ctx.Tr("repo.editor.push_rejected_summary"),
"Details": utils.SanitizeFlashErrorString(errPushRej.Message),

View file

@ -952,7 +952,7 @@ func renderErrorOfTemplates(ctx *context.Context, errs map[string]error) string
lines = append(lines, fmt.Sprintf("%s: %v", file, errs[file]))
}
flashError, err := ctx.RenderToString(tplAlertDetails, map[string]interface{}{
flashError, err := ctx.RenderToString(tplAlertDetails, map[string]any{
"Message": ctx.Tr("repo.issues.choose.ignore_invalid_templates"),
"Summary": ctx.Tr("repo.issues.choose.invalid_templates", len(errs)),
"Details": utils.SanitizeFlashErrorString(strings.Join(lines, "\n")),
@ -2081,7 +2081,7 @@ func UpdateIssueTitle(ctx *context.Context) {
return
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"title": issue.Title,
})
}
@ -2105,7 +2105,7 @@ func UpdateIssueRef(ctx *context.Context) {
return
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"ref": ref,
})
}
@ -2146,7 +2146,7 @@ func UpdateIssueContent(ctx *context.Context) {
return
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"content": content,
"attachments": attachmentsHTML(ctx, issue.Attachments, issue.Content),
})
@ -2206,7 +2206,7 @@ func UpdateIssueMilestone(ctx *context.Context) {
}
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"ok": true,
})
}
@ -2252,7 +2252,7 @@ func UpdateIssueAssignee(ctx *context.Context) {
}
}
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"ok": true,
})
}
@ -2377,7 +2377,7 @@ func UpdatePullReviewRequest(ctx *context.Context) {
}
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"ok": true,
})
}
@ -2763,7 +2763,7 @@ func UpdateIssueStatus(ctx *context.Context) {
if issue.IsClosed != isClosed {
if err := issue_service.ChangeStatus(issue, ctx.Doer, "", isClosed); err != nil {
if issues_model.IsErrDependenciesLeft(err) {
ctx.JSON(http.StatusPreconditionFailed, map[string]interface{}{
ctx.JSON(http.StatusPreconditionFailed, map[string]any{
"error": ctx.Tr("repo.issues.dependency.issue_batch_close_blocked", issue.Index),
})
return
@ -2978,7 +2978,7 @@ func UpdateCommentContent(ctx *context.Context) {
oldContent := comment.Content
comment.Content = ctx.FormString("content")
if len(comment.Content) == 0 {
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"content": "",
})
return
@ -3012,7 +3012,7 @@ func UpdateCommentContent(ctx *context.Context) {
return
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"content": content,
"attachments": attachmentsHTML(ctx, comment.Attachments, comment.Content),
})
@ -3122,14 +3122,14 @@ func ChangeIssueReaction(ctx *context.Context) {
}
if len(issue.Reactions) == 0 {
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"empty": true,
"html": "",
})
return
}
html, err := ctx.RenderToString(tplReactions, map[string]interface{}{
html, err := ctx.RenderToString(tplReactions, map[string]any{
"ctxData": ctx.Data,
"ActionURL": fmt.Sprintf("%s/issues/%d/reactions", ctx.Repo.RepoLink, issue.Index),
"Reactions": issue.Reactions.GroupByType(),
@ -3138,7 +3138,7 @@ func ChangeIssueReaction(ctx *context.Context) {
ctx.ServerError("ChangeIssueReaction.HTMLString", err)
return
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"html": html,
})
}
@ -3224,14 +3224,14 @@ func ChangeCommentReaction(ctx *context.Context) {
}
if len(comment.Reactions) == 0 {
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"empty": true,
"html": "",
})
return
}
html, err := ctx.RenderToString(tplReactions, map[string]interface{}{
html, err := ctx.RenderToString(tplReactions, map[string]any{
"ctxData": ctx.Data,
"ActionURL": fmt.Sprintf("%s/comments/%d/reactions", ctx.Repo.RepoLink, comment.ID),
"Reactions": comment.Reactions.GroupByType(),
@ -3240,7 +3240,7 @@ func ChangeCommentReaction(ctx *context.Context) {
ctx.ServerError("ChangeCommentReaction.HTMLString", err)
return
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"html": html,
})
}
@ -3313,7 +3313,7 @@ func GetCommentAttachments(ctx *context.Context) {
ctx.JSON(http.StatusOK, attachments)
}
func updateAttachments(ctx *context.Context, item interface{}, files []string) error {
func updateAttachments(ctx *context.Context, item any, files []string) error {
var attachments []*repo_model.Attachment
switch content := item.(type) {
case *issues_model.Issue:
@ -3357,7 +3357,7 @@ func updateAttachments(ctx *context.Context, item interface{}, files []string) e
}
func attachmentsHTML(ctx *context.Context, attachments []*repo_model.Attachment, content string) string {
attachHTML, err := ctx.RenderToString(tplAttachment, map[string]interface{}{
attachHTML, err := ctx.RenderToString(tplAttachment, map[string]any{
"ctxData": ctx.Data,
"Attachments": attachments,
"Content": content,

View file

@ -29,8 +29,8 @@ func GetContentHistoryOverview(ctx *context.Context) {
}
editedHistoryCountMap, _ := issues_model.QueryIssueContentHistoryEditedCountMap(ctx, issue.ID)
ctx.JSON(http.StatusOK, map[string]interface{}{
"i18n": map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"i18n": map[string]any{
"textEdited": ctx.Tr("repo.issues.content_history.edited"),
"textDeleteFromHistory": ctx.Tr("repo.issues.content_history.delete_from_history"),
"textDeleteFromHistoryConfirm": ctx.Tr("repo.issues.content_history.delete_from_history_confirm"),
@ -53,7 +53,7 @@ func GetContentHistoryList(ctx *context.Context) {
// render history list to HTML for frontend dropdown items: (name, value)
// name is HTML of "avatar + userName + userAction + timeSince"
// value is historyId
var results []map[string]interface{}
var results []map[string]any
for _, item := range items {
var actionText string
if item.IsDeleted {
@ -76,13 +76,13 @@ func GetContentHistoryList(ctx *context.Context) {
avatarHTML := string(templates.AvatarHTML(src, 28, class, username))
timeSinceText := string(timeutil.TimeSinceUnix(item.EditedUnix, ctx.Locale))
results = append(results, map[string]interface{}{
results = append(results, map[string]any{
"name": avatarHTML + "<strong>" + name + "</strong> " + actionText + " " + timeSinceText,
"value": item.HistoryID,
})
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"results": results,
})
}
@ -120,7 +120,7 @@ func GetContentHistoryDetail(ctx *context.Context) {
historyID := ctx.FormInt64("history_id")
history, prevHistory, err := issues_model.GetIssueContentHistoryAndPrev(ctx, historyID)
if err != nil {
ctx.JSON(http.StatusNotFound, map[string]interface{}{
ctx.JSON(http.StatusNotFound, map[string]any{
"message": "Can not find the content history",
})
return
@ -168,7 +168,7 @@ func GetContentHistoryDetail(ctx *context.Context) {
}
diffHTMLBuf.WriteString("</pre>")
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"canSoftDelete": canSoftDeleteContentHistory(ctx, issue, comment, history),
"historyId": historyID,
"prevHistoryId": prevHistoryID,
@ -202,7 +202,7 @@ func SoftDeleteContentHistory(ctx *context.Context) {
canSoftDelete := canSoftDeleteContentHistory(ctx, issue, comment, history)
if !canSoftDelete {
ctx.JSON(http.StatusForbidden, map[string]interface{}{
ctx.JSON(http.StatusForbidden, map[string]any{
"message": "Can not delete the content history",
})
return
@ -210,7 +210,7 @@ func SoftDeleteContentHistory(ctx *context.Context) {
err = issues_model.SoftDeleteIssueContentHistory(ctx, historyID)
log.Debug("soft delete issue content history. issue=%d, comment=%d, history=%d", issue.ID, commentID, historyID)
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"ok": err == nil,
})
}

View file

@ -157,7 +157,7 @@ func DeleteLabel(ctx *context.Context) {
ctx.Flash.Success(ctx.Tr("repo.issues.label_deletion_success"))
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": ctx.Repo.RepoLink + "/labels",
})
}
@ -226,7 +226,7 @@ func UpdateIssueLabel(ctx *context.Context) {
return
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"ok": true,
})
}

View file

@ -256,7 +256,7 @@ func DeleteMilestone(ctx *context.Context) {
ctx.Flash.Success(ctx.Tr("repo.milestones.deletion_success"))
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": ctx.Repo.RepoLink + "/milestones",
})
}

View file

@ -203,7 +203,7 @@ func DeleteProject(ctx *context.Context) {
ctx.Flash.Success(ctx.Tr("repo.projects.deletion_success"))
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": ctx.Repo.RepoLink + "/projects",
})
}
@ -398,7 +398,7 @@ func UpdateIssueProject(ctx *context.Context) {
}
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"ok": true,
})
}
@ -453,7 +453,7 @@ func DeleteProjectBoard(ctx *context.Context) {
return
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"ok": true,
})
}
@ -488,7 +488,7 @@ func AddBoardToProjectPost(ctx *context.Context) {
return
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"ok": true,
})
}
@ -562,7 +562,7 @@ func EditProjectBoard(ctx *context.Context) {
return
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"ok": true,
})
}
@ -579,7 +579,7 @@ func SetDefaultProjectBoard(ctx *context.Context) {
return
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"ok": true,
})
}
@ -596,7 +596,7 @@ func UnSetDefaultProjectBoard(ctx *context.Context) {
return
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"ok": true,
})
}
@ -700,7 +700,7 @@ func MoveIssues(ctx *context.Context) {
return
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"ok": true,
})
}

View file

@ -802,7 +802,7 @@ func ViewPullFiles(ctx *context.Context) {
return
}
ctx.PageData["prReview"] = map[string]interface{}{
ctx.PageData["prReview"] = map[string]any{
"numberOfFiles": diff.NumFiles,
"numberOfViewedFiles": diff.NumViewedFiles,
}
@ -937,7 +937,7 @@ func UpdatePullRequest(ctx *context.Context) {
if err = pull_service.Update(ctx, issue.PullRequest, ctx.Doer, message, rebase); err != nil {
if models.IsErrMergeConflicts(err) {
conflictError := err.(models.ErrMergeConflicts)
flashError, err := ctx.RenderToString(tplAlertDetails, map[string]interface{}{
flashError, err := ctx.RenderToString(tplAlertDetails, map[string]any{
"Message": ctx.Tr("repo.pulls.merge_conflict"),
"Summary": ctx.Tr("repo.pulls.merge_conflict_summary"),
"Details": utils.SanitizeFlashErrorString(conflictError.StdErr) + "<br>" + utils.SanitizeFlashErrorString(conflictError.StdOut),
@ -951,7 +951,7 @@ func UpdatePullRequest(ctx *context.Context) {
return
} else if models.IsErrRebaseConflicts(err) {
conflictError := err.(models.ErrRebaseConflicts)
flashError, err := ctx.RenderToString(tplAlertDetails, map[string]interface{}{
flashError, err := ctx.RenderToString(tplAlertDetails, map[string]any{
"Message": ctx.Tr("repo.pulls.rebase_conflict", utils.SanitizeFlashErrorString(conflictError.CommitSHA)),
"Summary": ctx.Tr("repo.pulls.rebase_conflict_summary"),
"Details": utils.SanitizeFlashErrorString(conflictError.StdErr) + "<br>" + utils.SanitizeFlashErrorString(conflictError.StdOut),
@ -1086,7 +1086,7 @@ func MergePullRequest(ctx *context.Context) {
ctx.Redirect(issue.Link())
} else if models.IsErrMergeConflicts(err) {
conflictError := err.(models.ErrMergeConflicts)
flashError, err := ctx.RenderToString(tplAlertDetails, map[string]interface{}{
flashError, err := ctx.RenderToString(tplAlertDetails, map[string]any{
"Message": ctx.Tr("repo.editor.merge_conflict"),
"Summary": ctx.Tr("repo.editor.merge_conflict_summary"),
"Details": utils.SanitizeFlashErrorString(conflictError.StdErr) + "<br>" + utils.SanitizeFlashErrorString(conflictError.StdOut),
@ -1099,7 +1099,7 @@ func MergePullRequest(ctx *context.Context) {
ctx.Redirect(issue.Link())
} else if models.IsErrRebaseConflicts(err) {
conflictError := err.(models.ErrRebaseConflicts)
flashError, err := ctx.RenderToString(tplAlertDetails, map[string]interface{}{
flashError, err := ctx.RenderToString(tplAlertDetails, map[string]any{
"Message": ctx.Tr("repo.pulls.rebase_conflict", utils.SanitizeFlashErrorString(conflictError.CommitSHA)),
"Summary": ctx.Tr("repo.pulls.rebase_conflict_summary"),
"Details": utils.SanitizeFlashErrorString(conflictError.StdErr) + "<br>" + utils.SanitizeFlashErrorString(conflictError.StdOut),
@ -1129,7 +1129,7 @@ func MergePullRequest(ctx *context.Context) {
if len(message) == 0 {
ctx.Flash.Error(ctx.Tr("repo.pulls.push_rejected_no_message"))
} else {
flashError, err := ctx.RenderToString(tplAlertDetails, map[string]interface{}{
flashError, err := ctx.RenderToString(tplAlertDetails, map[string]any{
"Message": ctx.Tr("repo.pulls.push_rejected"),
"Summary": ctx.Tr("repo.pulls.push_rejected_summary"),
"Details": utils.SanitizeFlashErrorString(pushrejErr.Message),
@ -1302,7 +1302,7 @@ func CompareAndPullRequestPost(ctx *context.Context) {
ctx.JSONError(ctx.Tr("repo.pulls.push_rejected_no_message"))
return
}
flashError, err := ctx.RenderToString(tplAlertDetails, map[string]interface{}{
flashError, err := ctx.RenderToString(tplAlertDetails, map[string]any{
"Message": ctx.Tr("repo.pulls.push_rejected"),
"Summary": ctx.Tr("repo.pulls.push_rejected_summary"),
"Details": utils.SanitizeFlashErrorString(pushrejErr.Message),
@ -1407,7 +1407,7 @@ func CleanUpPullRequest(ctx *context.Context) {
}
defer func() {
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": issue.Link(),
})
}()
@ -1519,7 +1519,7 @@ func UpdatePullRequestTarget(ctx *context.Context) {
errorMessage := ctx.Tr("repo.pulls.has_pull_request", html.EscapeString(ctx.Repo.RepoLink+"/pulls/"+strconv.FormatInt(err.IssueID, 10)), html.EscapeString(RepoRelPath), err.IssueID) // FIXME: Creates url inside locale string
ctx.Flash.Error(errorMessage)
ctx.JSON(http.StatusConflict, map[string]interface{}{
ctx.JSON(http.StatusConflict, map[string]any{
"error": err.Error(),
"user_error": errorMessage,
})
@ -1527,7 +1527,7 @@ func UpdatePullRequestTarget(ctx *context.Context) {
errorMessage := ctx.Tr("repo.pulls.is_closed")
ctx.Flash.Error(errorMessage)
ctx.JSON(http.StatusConflict, map[string]interface{}{
ctx.JSON(http.StatusConflict, map[string]any{
"error": err.Error(),
"user_error": errorMessage,
})
@ -1535,7 +1535,7 @@ func UpdatePullRequestTarget(ctx *context.Context) {
errorMessage := ctx.Tr("repo.pulls.has_merged")
ctx.Flash.Error(errorMessage)
ctx.JSON(http.StatusConflict, map[string]interface{}{
ctx.JSON(http.StatusConflict, map[string]any{
"error": err.Error(),
"user_error": errorMessage,
})
@ -1543,7 +1543,7 @@ func UpdatePullRequestTarget(ctx *context.Context) {
errorMessage := ctx.Tr("repo.pulls.nothing_to_compare")
ctx.Flash.Error(errorMessage)
ctx.JSON(http.StatusBadRequest, map[string]interface{}{
ctx.JSON(http.StatusBadRequest, map[string]any{
"error": err.Error(),
"user_error": errorMessage,
})
@ -1554,7 +1554,7 @@ func UpdatePullRequestTarget(ctx *context.Context) {
}
notification.NotifyPullRequestChangeTargetBranch(ctx, ctx.Doer, pr, targetBranch)
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"base_branch": pr.BaseBranch,
})
}
@ -1582,7 +1582,7 @@ func SetAllowEdits(ctx *context.Context) {
return
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"allow_maintainer_edit": pr.AllowMaintainerEdit,
})
}

View file

@ -153,7 +153,7 @@ func UpdateResolveConversation(ctx *context.Context) {
renderConversation(ctx, comment)
return
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"ok": true,
})
}

View file

@ -607,13 +607,13 @@ func deleteReleaseOrTag(ctx *context.Context, isDelTag bool) {
}
if isDelTag {
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": ctx.Repo.RepoLink + "/tags",
})
return
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": ctx.Repo.RepoLink + "/releases",
})
}

View file

@ -181,7 +181,7 @@ func Create(ctx *context.Context) {
ctx.HTML(http.StatusOK, tplCreate)
}
func handleCreateError(ctx *context.Context, owner *user_model.User, err error, name string, tpl base.TplName, form interface{}) {
func handleCreateError(ctx *context.Context, owner *user_model.User, err error, name string, tpl base.TplName, form any) {
switch {
case repo_model.IsErrReachLimitOfRepo(err):
maxCreationLimit := owner.MaxCreationLimit()
@ -482,7 +482,7 @@ func InitiateDownload(ctx *context.Context) {
completed = true
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"complete": completed,
})
}

View file

@ -133,7 +133,7 @@ func DeleteCollaboration(ctx *context.Context) {
ctx.Flash.Success(ctx.Tr("repo.settings.remove_collaborator_success"))
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": ctx.Repo.RepoLink + "/settings/collaboration",
})
}
@ -204,7 +204,7 @@ func DeleteTeam(ctx *context.Context) {
}
ctx.Flash.Success(ctx.Tr("repo.settings.remove_team_success"))
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": ctx.Repo.RepoLink + "/settings/collaboration",
})
}

View file

@ -105,7 +105,7 @@ func DeleteDeployKey(ctx *context.Context) {
ctx.Flash.Success(ctx.Tr("repo.settings.deploy_key_deletion_success"))
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": ctx.Repo.RepoLink + "/settings/keys",
})
}

View file

@ -307,7 +307,7 @@ func DeleteProtectedBranchRulePost(ctx *context.Context) {
ruleID := ctx.ParamsInt64("id")
if ruleID <= 0 {
ctx.Flash.Error(ctx.Tr("repo.settings.remove_protected_branch_failed", fmt.Sprintf("%d", ruleID)))
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": fmt.Sprintf("%s/settings/branches", ctx.Repo.RepoLink),
})
return
@ -316,7 +316,7 @@ func DeleteProtectedBranchRulePost(ctx *context.Context) {
rule, err := git_model.GetProtectedBranchRuleByID(ctx, ctx.Repo.Repository.ID, ruleID)
if err != nil {
ctx.Flash.Error(ctx.Tr("repo.settings.remove_protected_branch_failed", fmt.Sprintf("%d", ruleID)))
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": fmt.Sprintf("%s/settings/branches", ctx.Repo.RepoLink),
})
return
@ -324,7 +324,7 @@ func DeleteProtectedBranchRulePost(ctx *context.Context) {
if rule == nil {
ctx.Flash.Error(ctx.Tr("repo.settings.remove_protected_branch_failed", fmt.Sprintf("%d", ruleID)))
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": fmt.Sprintf("%s/settings/branches", ctx.Repo.RepoLink),
})
return
@ -332,14 +332,14 @@ func DeleteProtectedBranchRulePost(ctx *context.Context) {
if err := git_model.DeleteProtectedBranch(ctx, ctx.Repo.Repository.ID, ruleID); err != nil {
ctx.Flash.Error(ctx.Tr("repo.settings.remove_protected_branch_failed", rule.RuleName))
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": fmt.Sprintf("%s/settings/branches", ctx.Repo.RepoLink),
})
return
}
ctx.Flash.Success(ctx.Tr("repo.settings.remove_protected_branch_success", rule.RuleName))
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": fmt.Sprintf("%s/settings/branches", ctx.Repo.RepoLink),
})
}

View file

@ -145,7 +145,7 @@ func WebhooksNew(ctx *context.Context) {
return
}
if hookType == "discord" {
ctx.Data["DiscordHook"] = map[string]interface{}{
ctx.Data["DiscordHook"] = map[string]any{
"Username": "Gitea",
}
}
@ -196,7 +196,7 @@ type webhookParams struct {
Secret string
HTTPMethod string
WebhookForm forms.WebhookForm
Meta interface{}
Meta any
}
func createWebhook(ctx *context.Context, params webhookParams) {
@ -729,7 +729,7 @@ func DeleteWebhook(ctx *context.Context) {
ctx.Flash.Success(ctx.Tr("repo.settings.webhook_deletion_success"))
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": ctx.Repo.RepoLink + "/settings/hooks",
})
}

View file

@ -15,7 +15,7 @@ import (
// TopicsPost response for creating repository
func TopicsPost(ctx *context.Context) {
if ctx.Doer == nil {
ctx.JSON(http.StatusForbidden, map[string]interface{}{
ctx.JSON(http.StatusForbidden, map[string]any{
"message": "Only owners could change the topics.",
})
return
@ -30,7 +30,7 @@ func TopicsPost(ctx *context.Context) {
validTopics, invalidTopics := repo_model.SanitizeAndValidateTopics(topics)
if len(validTopics) > 25 {
ctx.JSON(http.StatusUnprocessableEntity, map[string]interface{}{
ctx.JSON(http.StatusUnprocessableEntity, map[string]any{
"invalidTopics": nil,
"message": ctx.Tr("repo.topic.count_prompt"),
})
@ -38,7 +38,7 @@ func TopicsPost(ctx *context.Context) {
}
if len(invalidTopics) > 0 {
ctx.JSON(http.StatusUnprocessableEntity, map[string]interface{}{
ctx.JSON(http.StatusUnprocessableEntity, map[string]any{
"invalidTopics": invalidTopics,
"message": ctx.Tr("repo.topic.format_prompt"),
})
@ -48,13 +48,13 @@ func TopicsPost(ctx *context.Context) {
err := repo_model.SaveTopics(ctx.Repo.Repository.ID, validTopics...)
if err != nil {
log.Error("SaveTopics failed: %v", err)
ctx.JSON(http.StatusInternalServerError, map[string]interface{}{
ctx.JSON(http.StatusInternalServerError, map[string]any{
"message": "Save topics failed.",
})
return
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"status": "ok",
})
}

View file

@ -791,7 +791,7 @@ func DeleteWikiPagePost(ctx *context.Context) {
notification.NotifyDeleteWikiPage(ctx, ctx.Doer, ctx.Repo.Repository, string(wikiName))
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": ctx.Repo.RepoLink + "/wiki/",
})
}

View file

@ -62,7 +62,7 @@ func assertWikiNotExists(t *testing.T, repo *repo_model.Repository, wikiName wik
assert.Nil(t, wikiEntry(t, repo, wikiName))
}
func assertPagesMetas(t *testing.T, expectedNames []string, metas interface{}) {
func assertPagesMetas(t *testing.T, expectedNames []string, metas any) {
pageMetas, ok := metas.([]PageMeta)
if !assert.True(t, ok) {
return

View file

@ -160,7 +160,7 @@ func RunnerDeletePost(ctx *context.Context, runnerID int64,
log.Warn("DeleteRunnerPost.UpdateRunner failed: %v, url: %s", err, ctx.Req.URL)
ctx.Flash.Warning(ctx.Tr("actions.runners.delete_runner_failed"))
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": failedRedirectTo,
})
return
@ -170,7 +170,7 @@ func RunnerDeletePost(ctx *context.Context, runnerID int64,
ctx.Flash.Success(ctx.Tr("actions.runners.delete_runner_success"))
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": successRedirectTo,
})
}

View file

@ -97,7 +97,7 @@ func Dashboard(ctx *context.Context) {
uid = ctxUser.ID
}
ctx.PageData["dashboardRepoList"] = map[string]interface{}{
ctx.PageData["dashboardRepoList"] = map[string]any{
"searchLimit": setting.UI.User.RepoPagingNum,
"uid": uid,
}

View file

@ -28,7 +28,7 @@ func Search(ctx *context.Context) {
ListOptions: listOptions,
})
if err != nil {
ctx.JSON(http.StatusInternalServerError, map[string]interface{}{
ctx.JSON(http.StatusInternalServerError, map[string]any{
"ok": false,
"error": err.Error(),
})
@ -37,7 +37,7 @@ func Search(ctx *context.Context) {
ctx.SetTotalCountHeader(maxResults)
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"ok": true,
"data": convert.ToUsers(ctx, ctx.Doer, users),
})

View file

@ -227,7 +227,7 @@ func DeleteEmail(ctx *context.Context) {
log.Trace("Email address deleted: %s", ctx.Doer.Name)
ctx.Flash.Success(ctx.Tr("settings.email_deletion_success"))
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": setting.AppSubURL + "/user/settings/account",
})
}

View file

@ -83,7 +83,7 @@ func DeleteApplication(ctx *context.Context) {
ctx.Flash.Success(ctx.Tr("settings.delete_token_success"))
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": setting.AppSubURL + "/user/settings/applications",
})
}

View file

@ -256,7 +256,7 @@ func DeleteKey(ctx *context.Context) {
ctx.Flash.Warning("Function not implemented")
ctx.Redirect(setting.AppSubURL + "/user/settings/keys")
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": setting.AppSubURL + "/user/settings/keys",
})
}

View file

@ -138,7 +138,7 @@ func (oa *OAuth2CommonHandlers) DeleteApp(ctx *context.Context) {
}
ctx.Flash.Success(ctx.Tr("settings.remove_oauth2_application_success"))
ctx.JSON(http.StatusOK, map[string]interface{}{"redirect": oa.BasePathList})
ctx.JSON(http.StatusOK, map[string]any{"redirect": oa.BasePathList})
}
// RevokeGrant revokes the grant
@ -149,5 +149,5 @@ func (oa *OAuth2CommonHandlers) RevokeGrant(ctx *context.Context) {
}
ctx.Flash.Success(ctx.Tr("settings.revoke_oauth2_grant_success"))
ctx.JSON(http.StatusOK, map[string]interface{}{"redirect": oa.BasePathList})
ctx.JSON(http.StatusOK, map[string]any{"redirect": oa.BasePathList})
}

View file

@ -112,7 +112,7 @@ func DeleteOpenID(ctx *context.Context) {
log.Trace("OpenID address deleted: %s", ctx.Doer.Name)
ctx.Flash.Success(ctx.Tr("settings.openid_deletion_success"))
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": setting.AppSubURL + "/user/settings/security",
})
}

View file

@ -48,7 +48,7 @@ func DeleteAccountLink(ctx *context.Context) {
}
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": setting.AppSubURL + "/user/settings/security",
})
}

View file

@ -116,7 +116,7 @@ func WebauthnDelete(ctx *context.Context) {
ctx.ServerError("GetWebAuthnCredentialByID", err)
return
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": setting.AppSubURL + "/user/settings/security",
})
}

View file

@ -42,7 +42,7 @@ func DeleteWebhook(ctx *context.Context) {
ctx.Flash.Success(ctx.Tr("repo.settings.webhook_deletion_success"))
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"redirect": setting.AppSubURL + "/user/settings/hooks",
})
}

View file

@ -17,12 +17,12 @@ func TaskStatus(ctx *context.Context) {
task, opts, err := admin_model.GetMigratingTaskByID(ctx.ParamsInt64("task"), ctx.Doer.ID)
if err != nil {
if admin_model.IsErrTaskDoesNotExist(err) {
ctx.JSON(http.StatusNotFound, map[string]interface{}{
ctx.JSON(http.StatusNotFound, map[string]any{
"error": "task `" + strconv.FormatInt(ctx.ParamsInt64("task"), 10) + "` does not exist",
})
return
}
ctx.JSON(http.StatusInternalServerError, map[string]interface{}{
ctx.JSON(http.StatusInternalServerError, map[string]any{
"err": err,
})
return
@ -36,13 +36,13 @@ func TaskStatus(ctx *context.Context) {
if err := json.Unmarshal([]byte(message), &translatableMessage); err != nil {
translatableMessage = admin_model.TranslatableMessage{
Format: "migrate.migrating_failed.error",
Args: []interface{}{task.Message},
Args: []any{task.Message},
}
}
message = ctx.Tr(translatableMessage.Format, translatableMessage.Args...)
}
ctx.JSON(http.StatusOK, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]any{
"status": task.Status,
"message": message,
"repo-id": task.RepoID,

View file

@ -18,18 +18,18 @@ import (
// https://datatracker.ietf.org/doc/html/draft-ietf-appsawg-webfinger-14#section-4.4
type webfingerJRD struct {
Subject string `json:"subject,omitempty"`
Aliases []string `json:"aliases,omitempty"`
Properties map[string]interface{} `json:"properties,omitempty"`
Links []*webfingerLink `json:"links,omitempty"`
Subject string `json:"subject,omitempty"`
Aliases []string `json:"aliases,omitempty"`
Properties map[string]any `json:"properties,omitempty"`
Links []*webfingerLink `json:"links,omitempty"`
}
type webfingerLink struct {
Rel string `json:"rel,omitempty"`
Type string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Titles map[string]string `json:"titles,omitempty"`
Properties map[string]interface{} `json:"properties,omitempty"`
Rel string `json:"rel,omitempty"`
Type string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Titles map[string]string `json:"titles,omitempty"`
Properties map[string]any `json:"properties,omitempty"`
}
// WebfingerQuery returns information about a resource