diff options
author | 6543 <6543@obermui.de> | 2021-01-17 21:48:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-17 21:48:38 +0100 |
commit | 21da519c0cd6e243888ebe573e3496e4eda01f10 (patch) | |
tree | a4e2fe5cf6dae77091e8089fa6b98c8684b07fe1 /routers/user | |
parent | ca63a9d3f1120d8c76eb83ff1fd07e0992a683a8 (diff) | |
download | gitea-21da519c0cd6e243888ebe573e3496e4eda01f10.tar.gz gitea-21da519c0cd6e243888ebe573e3496e4eda01f10.zip |
Implement ghost comment mitigation (#14349)
* Implement ghost comment mitigation
Adds a config option USER_DELETE_WITH_COMMENTS_MAX_DAYS to the [service] section. See https://codeberg.org/Codeberg/Discussion/issues/24 for the underlying issue.
* cleanup
* use setting module correctly
* add to docs
Co-authored-by: Moritz Marquardt <git@momar.de>
Diffstat (limited to 'routers/user')
-rw-r--r-- | routers/user/setting/account.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/routers/user/setting/account.go b/routers/user/setting/account.go index ca9b5b3c32..3b4191f0be 100644 --- a/routers/user/setting/account.go +++ b/routers/user/setting/account.go @@ -7,6 +7,7 @@ package setting import ( "errors" + "time" "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/auth" @@ -300,4 +301,9 @@ func loadAccountData(ctx *context.Context) { ctx.Data["EmailNotificationsPreference"] = ctx.User.EmailNotifications() ctx.Data["ActivationsPending"] = pendingActivation ctx.Data["CanAddEmails"] = !pendingActivation || !setting.Service.RegisterEmailConfirm + + if setting.Service.UserDeleteWithCommentsMaxDays != 0 { + ctx.Data["UserDeleteWithCommentsMaxDays"] = setting.Service.UserDeleteWithCommentsMaxDays + ctx.Data["UserDeleteWithComments"] = ctx.User.CreatedUnix.AsTime().Add(time.Duration(setting.Service.UserDeleteWithCommentsMaxDays) * 24 * time.Hour).After(time.Now()) + } } |