diff options
author | silverwind <me@silverwind.io> | 2023-07-04 20:36:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-04 18:36:08 +0000 |
commit | 88f835192d1a554d233b0ec4daa33276b7eb2910 (patch) | |
tree | 438140c295791e64a3b78dcfeae57701bcf296c3 /routers/web | |
parent | 00dbba7f4266032a2b91b760e7c611950ffad096 (diff) | |
download | gitea-88f835192d1a554d233b0ec4daa33276b7eb2910.tar.gz gitea-88f835192d1a554d233b0ec4daa33276b7eb2910.zip |
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](https://github.com/golang/go/commit/2580d0e08d5e9f979b943758d3c49877fb2324cb).
Diffstat (limited to 'routers/web')
49 files changed, 160 insertions, 160 deletions
diff --git a/routers/web/admin/auths.go b/routers/web/admin/auths.go index b6ea3ff403..adde26f0b5 100644 --- a/routers/web/admin/auths.go +++ b/routers/web/admin/auths.go @@ -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", }) } diff --git a/routers/web/admin/config.go b/routers/web/admin/config.go index 2c6989a71d..1c233ae852 100644 --- a/routers/web/admin/config.go +++ b/routers/web/admin/config.go @@ -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, }) } diff --git a/routers/web/admin/hooks.go b/routers/web/admin/hooks.go index 46dc734d25..2e4122c904 100644 --- a/routers/web/admin/hooks.go +++ b/routers/web/admin/hooks.go @@ -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", }) } diff --git a/routers/web/admin/packages.go b/routers/web/admin/packages.go index 4d5987e780..ace54fc0d8 100644 --- a/routers/web/admin/packages.go +++ b/routers/web/admin/packages.go @@ -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")), }) } diff --git a/routers/web/admin/repos.go b/routers/web/admin/repos.go index 9a0e467b48..2ea8a2ad35 100644 --- a/routers/web/admin/repos.go +++ b/routers/web/admin/repos.go @@ -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")), }) } diff --git a/routers/web/admin/stacktrace.go b/routers/web/admin/stacktrace.go index 4b225c2c8a..f2d2be481a 100644 --- a/routers/web/admin/stacktrace.go +++ b/routers/web/admin/stacktrace.go @@ -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", }) } diff --git a/routers/web/admin/users.go b/routers/web/admin/users.go index 3895bcfdb9..08a4076418 100644 --- a/routers/web/admin/users.go +++ b/routers/web/admin/users.go @@ -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, } diff --git a/routers/web/auth/auth.go b/routers/web/auth/auth.go index 9dcc38247d..9f13952257 100644 --- a/routers/web/auth/auth.go +++ b/routers/web/auth/auth.go @@ -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) } diff --git a/routers/web/auth/linkaccount.go b/routers/web/auth/linkaccount.go index 522e78a60a..0f7ecf1af4 100644 --- a/routers/web/auth/linkaccount.go +++ b/routers/web/auth/linkaccount.go @@ -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, diff --git a/routers/web/auth/oauth.go b/routers/web/auth/oauth.go index 0ce3bbde00..db15bf2e3d 100644 --- a/routers/web/auth/oauth.go +++ b/routers/web/auth/oauth.go @@ -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, diff --git a/routers/web/auth/oauth_test.go b/routers/web/auth/oauth_test.go index 62f723600d..adf933fd23 100644 --- a/routers/web/auth/oauth_test.go +++ b/routers/web/auth/oauth_test.go @@ -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 diff --git a/routers/web/auth/openid.go b/routers/web/auth/openid.go index 7a4bb7f209..00fc17f098 100644 --- a/routers/web/auth/openid.go +++ b/routers/web/auth/openid.go @@ -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, diff --git a/routers/web/explore/topic.go b/routers/web/explore/topic.go index e172d9e04d..132ef23fa7 100644 --- a/routers/web/explore/topic.go +++ b/routers/web/explore/topic.go @@ -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, }) } diff --git a/routers/web/org/members.go b/routers/web/org/members.go index 1953a8b284..8da0f0b9fd 100644 --- a/routers/web/org/members.go +++ b/routers/web/org/members.go @@ -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, }) } diff --git a/routers/web/org/org_labels.go b/routers/web/org/org_labels.go index 9ce05680d7..08566637a8 100644 --- a/routers/web/org/org_labels.go +++ b/routers/web/org/org_labels.go @@ -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", }) } diff --git a/routers/web/org/projects.go b/routers/web/org/projects.go index c568b1c071..4b33d943b3 100644 --- a/routers/web/org/projects.go +++ b/routers/web/org/projects.go @@ -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, }) } diff --git a/routers/web/org/setting.go b/routers/web/org/setting.go index 2c4a6b93e3..b5653160a2 100644 --- a/routers/web/org/setting.go +++ b/routers/web/org/setting.go @@ -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", }) } diff --git a/routers/web/org/teams.go b/routers/web/org/teams.go index 2ce4bf5322..aefadaf809 100644 --- a/routers/web/org/teams.go +++ b/routers/web/org/teams.go @@ -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", }) } diff --git a/routers/web/repo/branch.go b/routers/web/repo/branch.go index 8e3383848f..999104d787 100644 --- a/routers/web/repo/branch.go +++ b/routers/web/repo/branch.go @@ -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), diff --git a/routers/web/repo/editor.go b/routers/web/repo/editor.go index a63b08126c..88f9e42f3b 100644 --- a/routers/web/repo/editor.go +++ b/routers/web/repo/editor.go @@ -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), diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index 4f14cc381f..5e15df330c 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -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, diff --git a/routers/web/repo/issue_content_history.go b/routers/web/repo/issue_content_history.go index 7e5295e757..46a320a8cc 100644 --- a/routers/web/repo/issue_content_history.go +++ b/routers/web/repo/issue_content_history.go @@ -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, }) } diff --git a/routers/web/repo/issue_label.go b/routers/web/repo/issue_label.go index 002acbf1d3..af5db83bd5 100644 --- a/routers/web/repo/issue_label.go +++ b/routers/web/repo/issue_label.go @@ -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, }) } diff --git a/routers/web/repo/milestone.go b/routers/web/repo/milestone.go index 4b33fbcb16..38ef693967 100644 --- a/routers/web/repo/milestone.go +++ b/routers/web/repo/milestone.go @@ -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", }) } diff --git a/routers/web/repo/projects.go b/routers/web/repo/projects.go index b1033fe003..066cdbc5fd 100644 --- a/routers/web/repo/projects.go +++ b/routers/web/repo/projects.go @@ -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, }) } diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go index c543d90e19..ad04fb2d71 100644 --- a/routers/web/repo/pull.go +++ b/routers/web/repo/pull.go @@ -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, }) } diff --git a/routers/web/repo/pull_review.go b/routers/web/repo/pull_review.go index 5aa5811367..1645155bf8 100644 --- a/routers/web/repo/pull_review.go +++ b/routers/web/repo/pull_review.go @@ -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, }) } diff --git a/routers/web/repo/release.go b/routers/web/repo/release.go index 5fddddb344..32438a14da 100644 --- a/routers/web/repo/release.go +++ b/routers/web/repo/release.go @@ -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", }) } diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go index 781a12b2d9..d1ccb011bb 100644 --- a/routers/web/repo/repo.go +++ b/routers/web/repo/repo.go @@ -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, }) } diff --git a/routers/web/repo/setting/collaboration.go b/routers/web/repo/setting/collaboration.go index d3a9959104..8f2d306862 100644 --- a/routers/web/repo/setting/collaboration.go +++ b/routers/web/repo/setting/collaboration.go @@ -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", }) } diff --git a/routers/web/repo/setting/deploy_key.go b/routers/web/repo/setting/deploy_key.go index 9776095672..d08c51f5e5 100644 --- a/routers/web/repo/setting/deploy_key.go +++ b/routers/web/repo/setting/deploy_key.go @@ -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", }) } diff --git a/routers/web/repo/setting/protected_branch.go b/routers/web/repo/setting/protected_branch.go index 962b85d0cd..777d52c858 100644 --- a/routers/web/repo/setting/protected_branch.go +++ b/routers/web/repo/setting/protected_branch.go @@ -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), }) } diff --git a/routers/web/repo/setting/webhook.go b/routers/web/repo/setting/webhook.go index a1cedd9a31..d85d5c8b07 100644 --- a/routers/web/repo/setting/webhook.go +++ b/routers/web/repo/setting/webhook.go @@ -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", }) } diff --git a/routers/web/repo/topic.go b/routers/web/repo/topic.go index 4c0b38bd91..d22c3c6aa3 100644 --- a/routers/web/repo/topic.go +++ b/routers/web/repo/topic.go @@ -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", }) } diff --git a/routers/web/repo/wiki.go b/routers/web/repo/wiki.go index 22cfe6dd25..7da6917912 100644 --- a/routers/web/repo/wiki.go +++ b/routers/web/repo/wiki.go @@ -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/", }) } diff --git a/routers/web/repo/wiki_test.go b/routers/web/repo/wiki_test.go index d85879d1e5..e1284fad67 100644 --- a/routers/web/repo/wiki_test.go +++ b/routers/web/repo/wiki_test.go @@ -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 diff --git a/routers/web/shared/actions/runners.go b/routers/web/shared/actions/runners.go index c212c4ff25..21e5a90d8f 100644 --- a/routers/web/shared/actions/runners.go +++ b/routers/web/shared/actions/runners.go @@ -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, }) } diff --git a/routers/web/user/home.go b/routers/web/user/home.go index 2513fc9a98..1b0f651b07 100644 --- a/routers/web/user/home.go +++ b/routers/web/user/home.go @@ -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, } diff --git a/routers/web/user/search.go b/routers/web/user/search.go index bdc4116e37..fa2e52dd41 100644 --- a/routers/web/user/search.go +++ b/routers/web/user/search.go @@ -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), }) diff --git a/routers/web/user/setting/account.go b/routers/web/user/setting/account.go index a67c2398fb..532f0d8e39 100644 --- a/routers/web/user/setting/account.go +++ b/routers/web/user/setting/account.go @@ -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", }) } diff --git a/routers/web/user/setting/applications.go b/routers/web/user/setting/applications.go index f9e9ca5e52..8120937696 100644 --- a/routers/web/user/setting/applications.go +++ b/routers/web/user/setting/applications.go @@ -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", }) } diff --git a/routers/web/user/setting/keys.go b/routers/web/user/setting/keys.go index 6debf95bbc..d9412cae7c 100644 --- a/routers/web/user/setting/keys.go +++ b/routers/web/user/setting/keys.go @@ -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", }) } diff --git a/routers/web/user/setting/oauth2_common.go b/routers/web/user/setting/oauth2_common.go index 5de0f0e22f..923ce4b436 100644 --- a/routers/web/user/setting/oauth2_common.go +++ b/routers/web/user/setting/oauth2_common.go @@ -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}) } diff --git a/routers/web/user/setting/security/openid.go b/routers/web/user/setting/security/openid.go index 08fcb6b623..f4133f3916 100644 --- a/routers/web/user/setting/security/openid.go +++ b/routers/web/user/setting/security/openid.go @@ -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", }) } diff --git a/routers/web/user/setting/security/security.go b/routers/web/user/setting/security/security.go index 6e6e7efb0b..cc5f817a9d 100644 --- a/routers/web/user/setting/security/security.go +++ b/routers/web/user/setting/security/security.go @@ -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", }) } diff --git a/routers/web/user/setting/security/webauthn.go b/routers/web/user/setting/security/webauthn.go index 826562f157..89ac184a47 100644 --- a/routers/web/user/setting/security/webauthn.go +++ b/routers/web/user/setting/security/webauthn.go @@ -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", }) } diff --git a/routers/web/user/setting/webhooks.go b/routers/web/user/setting/webhooks.go index 9b0b0c9611..db03d7b1ed 100644 --- a/routers/web/user/setting/webhooks.go +++ b/routers/web/user/setting/webhooks.go @@ -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", }) } diff --git a/routers/web/user/task.go b/routers/web/user/task.go index 3818682403..d92bf64af0 100644 --- a/routers/web/user/task.go +++ b/routers/web/user/task.go @@ -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, diff --git a/routers/web/webfinger.go b/routers/web/webfinger.go index 1442e09a31..0966b04951 100644 --- a/routers/web/webfinger.go +++ b/routers/web/webfinger.go @@ -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 |