From 21da519c0cd6e243888ebe573e3496e4eda01f10 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sun, 17 Jan 2021 21:48:38 +0100 Subject: 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 --- routers/user/setting/account.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'routers/user') 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()) + } } -- cgit v1.2.3