1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

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
233 changed files with 727 additions and 727 deletions

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