[sysadmin-bin] Look for each of the users events and make sure there's none



commit 8ec9f5819ee10aa0418867a9e78984391f35bebf
Author: Andrea Veri <averi redhat com>
Date:   Fri Mar 22 12:36:35 2019 +0100

    Look for each of the users events and make sure there's none
    
    Be extra careful with the users deletion task and only remove accounts
    that in addition to the prerequisites listed in eb0e18e9 also looks
    whether an user really ever performed one of the actions listed at [1]
    before considering it fake, spammy.
    
    [1] https://docs.gitlab.com/ce/api/events.html

 gitlab/inactive-gitlab-users.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/gitlab/inactive-gitlab-users.py b/gitlab/inactive-gitlab-users.py
index 15d1f56..13c54c2 100755
--- a/gitlab/inactive-gitlab-users.py
+++ b/gitlab/inactive-gitlab-users.py
@@ -27,8 +27,9 @@ for user in users:
         if user.attributes['username'] != 'ghost':
             if not user.attributes['last_activity_on'] and user.attributes['current_sign_in_at']:
                 if user.attributes['email'].split('@')[1].split('.')[-2] not in whitelist:
-                    if user.attributes['created_at'].split('T')[0] == 
user.attributes['current_sign_in_at'].split('T')[0]:
-                        if dt.datetime.strptime(user.attributes['created_at'].split('T')[0], 
'%Y-%m-%d').date() < (today - timedelta):
-                            print '{},{},{},{},{}'.format(user.attributes['username'], 
user.attributes['email'], user.attributes['id'], user.attributes['created_at'].split('T')[0], 
user.attributes['current_sign_in_at'].split('T')[0])
+                    if len(user.events.list()) == 0:
+                        if user.attributes['created_at'].split('T')[0] == 
user.attributes['current_sign_in_at'].split('T')[0]:
+                            if dt.datetime.strptime(user.attributes['created_at'].split('T')[0], 
'%Y-%m-%d').date() < (today - timedelta):
+                                print '{},{},{},{},{}'.format(user.attributes['username'], 
user.attributes['email'], user.attributes['id'], user.attributes['created_at'].split('T')[0], 
user.attributes['current_sign_in_at'].split('T')[0])
     else:
         is_ldap = False


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