mirror of
https://github.com/go-gitea/gitea.git
synced 2026-12-04 15:54:57 +00:00
Fix various call sites including: * Fixes #40457 * Fixes #40456 --------- Signed-off-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: linzch3 <20380442+linzch3@users.noreply.github.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
34 lines
1020 B
Go
34 lines
1020 B
Go
// Copyright 2025 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package setting
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
user_model "gitea.dev/models/user"
|
|
"gitea.dev/modules/jsonlimit"
|
|
"gitea.dev/modules/setting"
|
|
"gitea.dev/services/context"
|
|
)
|
|
|
|
func SettingsCtxData(ctx *context.Context) {
|
|
ctx.Data["PageIsUserSettings"] = true
|
|
ctx.Data["EnablePackages"] = setting.Packages.Enabled
|
|
ctx.Data["EnableNotifyMail"] = setting.Service.EnableNotifyMail
|
|
ctx.Data["UserDisabledFeatures"] = user_model.DisabledFeaturesWithLoginType(ctx.Doer)
|
|
}
|
|
|
|
func UpdatePreferences(ctx *context.Context) {
|
|
type preferencesForm struct {
|
|
CodeViewShowFileTree bool `json:"codeViewShowFileTree"`
|
|
}
|
|
form := &preferencesForm{}
|
|
if err := jsonlimit.DecodeFromRequest(ctx.Resp, ctx.Req, 10*1024*1024, &form); err != nil {
|
|
ctx.JSONError("invalid request body")
|
|
return
|
|
}
|
|
_ = user_model.SetUserSetting(ctx, ctx.Doer.ID, user_model.SettingsKeyCodeViewShowFileTree, strconv.FormatBool(form.CodeViewShowFileTree))
|
|
ctx.JSONOK()
|
|
}
|