File tree Expand file tree Collapse file tree 8 files changed +28
-1
lines changed
docs/content/doc/advanced Expand file tree Collapse file tree 8 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -671,6 +671,9 @@ AUTO_WATCH_NEW_REPOS = true
671
671
; Default value for AutoWatchOnChanges
672
672
; Make the user watch a repository When they commit for the first time
673
673
AUTO_WATCH_ON_CHANGES = false
674
+ ; Default value for the minimum age a user has to exist before deletion to keep issue comments.
675
+ ; If a user deletes his account before that amount of days, his comments will be deleted as well.
676
+ USER_DELETE_WITH_COMMENTS_MAX_DAYS = 0
674
677
675
678
[webhook]
676
679
; Hook task queue length, increase if webhook shooting starts hanging
Original file line number Diff line number Diff line change @@ -474,6 +474,7 @@ relation to port exhaustion.
474
474
- ` ALLOW_ONLY_EXTERNAL_REGISTRATION ` : ** false** Set to true to force registration only using third-party services.
475
475
- ` NO_REPLY_ADDRESS ` : ** DOMAIN** Default value for the domain part of the user's email address in the git log if he has set KeepEmailPrivate to true.
476
476
The user's email will be replaced with a concatenation of the user name in lower case, "@" and NO_REPLY_ADDRESS.
477
+ - ` USER_DELETE_WITH_COMMENTS_MAX_DAYS ` : ** 0** If a user deletes his account before that amount of days, his comments will be deleted as well.
477
478
478
479
## SSH Minimum Key Sizes (` ssh.minimum_key_sizes ` )
479
480
Original file line number Diff line number Diff line change @@ -1141,6 +1141,15 @@ func deleteUser(e Engine, u *User) error {
1141
1141
return fmt .Errorf ("deleteBeans: %v" , err )
1142
1142
}
1143
1143
1144
+ if setting .Service .UserDeleteWithCommentsMaxDays != 0 &&
1145
+ u .CreatedUnix .AsTime ().Add (time .Duration (setting .Service .UserDeleteWithCommentsMaxDays )* 24 * time .Hour ).After (time .Now ()) {
1146
+ if err = deleteBeans (e ,
1147
+ & Comment {PosterID : u .ID },
1148
+ ); err != nil {
1149
+ return fmt .Errorf ("deleteBeans: %v" , err )
1150
+ }
1151
+ }
1152
+
1144
1153
// ***** START: PublicKey *****
1145
1154
if _ , err = e .Delete (& PublicKey {OwnerID : u .ID }); err != nil {
1146
1155
return fmt .Errorf ("deletePublicKeys: %v" , err )
@@ -1208,7 +1217,8 @@ func deleteUser(e Engine, u *User) error {
1208
1217
}
1209
1218
1210
1219
// DeleteUser completely and permanently deletes everything of a user,
1211
- // but issues/comments/pulls will be kept and shown as someone has been deleted.
1220
+ // but issues/comments/pulls will be kept and shown as someone has been deleted,
1221
+ // unless the user is younger than USER_DELETE_WITH_COMMENTS_MAX_DAYS.
1212
1222
func DeleteUser (u * User ) (err error ) {
1213
1223
if u .IsOrganization () {
1214
1224
return fmt .Errorf ("%s is an organization not a user" , u .Name )
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ var Service struct {
49
49
AutoWatchNewRepos bool
50
50
AutoWatchOnChanges bool
51
51
DefaultOrgMemberVisible bool
52
+ UserDeleteWithCommentsMaxDays int
52
53
53
54
// OpenID settings
54
55
EnableOpenIDSignIn bool
@@ -96,6 +97,7 @@ func newService() {
96
97
Service .DefaultOrgVisibility = sec .Key ("DEFAULT_ORG_VISIBILITY" ).In ("public" , structs .ExtractKeysFromMapString (structs .VisibilityModes ))
97
98
Service .DefaultOrgVisibilityMode = structs .VisibilityModes [Service .DefaultOrgVisibility ]
98
99
Service .DefaultOrgMemberVisible = sec .Key ("DEFAULT_ORG_MEMBER_VISIBLE" ).MustBool ()
100
+ Service .UserDeleteWithCommentsMaxDays = sec .Key ("USER_DELETE_WITH_COMMENTS_MAX_DAYS" ).MustInt (0 )
99
101
100
102
sec = Cfg .Section ("openid" )
101
103
Service .EnableOpenIDSignIn = sec .Key ("ENABLE_OPENID_SIGNIN" ).MustBool (! InstallLock )
Original file line number Diff line number Diff line change @@ -626,6 +626,7 @@ repos_none=Du besitzt keine Repositories
626
626
627
627
delete_account =Konto löschen
628
628
delete_prompt =Wenn du fortfährst, wird dein Account permanent gelöscht. Dies <strong>KANN NICHT</strong> rückgängig gemacht werden.
629
+ delete_with_all_comments = Dein Account ist jünger als %d Tage. Um Geisterkommentare zu vermeiden, werden alle Issue/PR-Kommentare zusammen mit deinem Benutzeraccount gelöscht.
629
630
confirm_delete_account =Löschen bestätigen
630
631
delete_account_title =Benutzerkonto löschen
631
632
delete_account_desc =Bist du sicher, dass du diesen Account dauerhaft löschen möchtest?
Original file line number Diff line number Diff line change @@ -640,6 +640,7 @@ repos_none = You do not own any repositories
640
640
641
641
delete_account = Delete Your Account
642
642
delete_prompt = This operation will permanently delete your user account. It <strong>CAN NOT</strong> be undone.
643
+ delete_with_all_comments = Your account is younger than %d days. To avoid ghost comments, all issue/PR comments will be deleted with it.
643
644
confirm_delete_account = Confirm Deletion
644
645
delete_account_title = Delete User Account
645
646
delete_account_desc = Are you sure you want to permanently delete this user account?
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ package setting
7
7
8
8
import (
9
9
"errors"
10
+ "time"
10
11
11
12
"code.gitea.io/gitea/models"
12
13
"code.gitea.io/gitea/modules/auth"
@@ -301,4 +302,9 @@ func loadAccountData(ctx *context.Context) {
301
302
ctx .Data ["EmailNotificationsPreference" ] = ctx .User .EmailNotifications ()
302
303
ctx .Data ["ActivationsPending" ] = pendingActivation
303
304
ctx .Data ["CanAddEmails" ] = ! pendingActivation || ! setting .Service .RegisterEmailConfirm
305
+
306
+ if setting .Service .UserDeleteWithCommentsMaxDays != 0 {
307
+ ctx .Data ["UserDeleteWithCommentsMaxDays" ] = setting .Service .UserDeleteWithCommentsMaxDays
308
+ ctx .Data ["UserDeleteWithComments" ] = ctx .User .CreatedUnix .AsTime ().Add (time .Duration (setting .Service .UserDeleteWithCommentsMaxDays ) * 24 * time .Hour ).After (time .Now ())
309
+ }
304
310
}
Original file line number Diff line number Diff line change 173
173
<div class="ui attached error segment">
174
174
<div class="ui red message">
175
175
<p class="text left">{{svg "octicon-alert"}} {{.i18n.Tr "settings.delete_prompt" | Str2html}}</p>
176
+ {{ if .UserDeleteWithComments }}
177
+ <p class="text left" style="font-weight: bold;">{{.i18n.Tr "settings.delete_with_all_comments" .UserDeleteWithCommentsMaxDays | Str2html}}</p>
178
+ {{ end }}
176
179
</div>
177
180
<form class="ui form ignore-dirty" id="delete-form" action="{{AppSubUrl}}/user/settings/account/delete" method="post">
178
181
{{.CsrfTokenHtml}}
You can’t perform that action at this time.
0 commit comments