Get only active user

This commit is contained in:
Mickael 2019-08-26 19:16:26 +02:00
parent fd2b60bfe8
commit 3069186812

View file

@ -21,9 +21,8 @@ def main():
rocket = RocketChat(None, None, auth_token= os.environ['ROCKETCHAT_AUTH'], user_id= os.environ['ROCKETCHAT_USERID'], server_url=os.environ['ROCKETCHAT_SERVER']) rocket = RocketChat(None, None, auth_token= os.environ['ROCKETCHAT_AUTH'], user_id= os.environ['ROCKETCHAT_USERID'], server_url=os.environ['ROCKETCHAT_SERVER'])
print("Check users") print("Check users")
users = rocket.users_list().json() users = getAllActiveUsers(rocket)
crapauds_total = len(users)
crapauds_total = users["total"]
print("Check channels") print("Check channels")
channels = getAllChannels(rocket) channels = getAllChannels(rocket)
@ -101,7 +100,7 @@ def getAllChannels(rocket):
index += channels['count'] index += channels['count']
return allChannels return allChannels
def getAllUsers(rocket): def getAllActiveUsers(rocket):
index = 0 index = 0
allUsers = [] allUsers = []
while True: while True:
@ -111,7 +110,7 @@ def getAllUsers(rocket):
if users['count'] + users['offset'] >= users['total']: if users['count'] + users['offset'] >= users['total']:
break break
index += users['count'] index += users['count']
return allUsers return list(filter( lambda user: user["active"] ,allUsers))
def getAllMessages(rocket, roomid, begindate): def getAllMessages(rocket, roomid, begindate):
index = 0 index = 0