[sysadmin-bin] Print user e-mail and reason for removal/block



commit 66b6d00a6145b7c332f5b547df590a53829a8a94
Author: Bartłomiej Piotrowski <bpiotrowski gnome org>
Date:   Wed Dec 1 08:07:34 2021 +0100

    Print user e-mail and reason for removal/block

 gitlab/inactive-gitlab-users.py | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
---
diff --git a/gitlab/inactive-gitlab-users.py b/gitlab/inactive-gitlab-users.py
index 47eb8d4..449260a 100755
--- a/gitlab/inactive-gitlab-users.py
+++ b/gitlab/inactive-gitlab-users.py
@@ -194,8 +194,7 @@ def delete_snippets_only_users(gl):
 
         events = user.events.list(all=True, lazy=True)
         if len(events) == 0:
-            print(f"removing {user.username}")
-            delete_user(gl, user.id)
+            delete_user(gl, user.id, "snippets")
 
 
 def trust_user(gl, user_id):
@@ -210,10 +209,10 @@ def untrust_user(gl, user_id):
     print(user_id)
 
 
-def delete_user(gl, user_id):
+def delete_user(gl, user_id, reason=""):
     try:
         user = gl.users.get(user_id)
-        print(user.username)
+        print(f"{user.username},{user.email},{user.reason}")
         gl.users.delete(user_id)
     except gitlab.exceptions.GitlabDeleteError:
         pass
@@ -222,8 +221,8 @@ def delete_user(gl, user_id):
 def block_user(gl, user_id):
     try:
         user = gl.users.get(user_id)
+        print(f"{user.username},{user.email},spam")
         user.block()
-        print(user_id)
     except gitlab.exceptions.GitlabBlockError:
         pass
 
@@ -324,7 +323,7 @@ if __name__ == "__main__":
                 block_user(gl, user["id"])
                 continue
 
-            delete_user(gl, user["id"])
+            delete_user(gl, user["id"], user["reason"])
     elif args.command == "trust-groups":
         trust_all_groups(gl)
     elif args.command == "trust-2fa":


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]