@@ -454,9 +454,12 @@ def __init__(self, log, user, token, base_url, admin_path, timeout, debug,
454
454
self .user = user
455
455
456
456
def user_list (self , _from , _limit , _guests , _deactivated ,
457
- _name , _user_id , _admin = None ):
457
+ _name , _user_id , _admin = None , order_by = None , _dir = None ,
458
+ not_user_type = None , locked = False ):
458
459
"""List and search users
459
460
461
+ https://element-hq.github.io/synapse/latest/admin_api/user_admin_api.html#list-accounts
462
+
460
463
Args:
461
464
_from (int): offsets user list by this number, used for pagination
462
465
_limit (int): maximum number of users returned, used for pagination
@@ -467,6 +470,19 @@ def user_list(self, _from, _limit, _guests, _deactivated,
467
470
_user_id (string): fully qualified Matrix user ID to search for
468
471
_admin (bool or None): whether to filter for admins. a None
469
472
does not filter.
473
+ order_by (string or None): Method of sorting returned users. See
474
+ Synapse's documentation for valid choices. None uses Synapse
475
+ defaults. Note that methods other than "name" or
476
+ "creation_ts" may be slow and cause a major load as they
477
+ have no database index.
478
+ _dir (string or None): Direction of sorting. "f" for forwards
479
+ (default or when None), "b" for backwards/reversed.
480
+ not_user_type (string or list or None): User type to exclude.
481
+ Supports list for multiple values. Possible values are
482
+ "bot", "support", or "" (to exclude users without a user
483
+ type). Defaults to None for no filtering.
484
+ locked (bool): Include locked users. Defaults to not
485
+ including them.
470
486
471
487
Returns:
472
488
string: JSON string containing the found users
@@ -478,14 +494,19 @@ def user_list(self, _from, _limit, _guests, _deactivated,
478
494
else None ),
479
495
"deactivated" : "true" if _deactivated else None ,
480
496
"name" : _name ,
481
- "user_id" : _user_id
497
+ "user_id" : _user_id ,
498
+ "order_by" : order_by ,
499
+ "dir" : _dir ,
500
+ "not_user_type" : not_user_type ,
501
+ "locked" : str (locked ).lower ()
482
502
}
483
503
if _admin is not None :
484
504
params ["admins" ] = str (_admin ).lower ()
485
505
return self .query ("get" , "v2/users" , params = params )
486
506
487
- def user_list_paginate (self , _limit , _guests , _deactivated ,
488
- _name , _user_id , _from = "0" , admin = None ):
507
+ def user_list_paginate (self , _limit , _guests , _deactivated , _name ,
508
+ _user_id , _from = "0" , admin = None , order_by = None ,
509
+ _dir = None , not_user_type = None , locked = False ):
489
510
# documentation is mostly duplicated from user_list...
490
511
"""Yields API responses for all of the pagination.
491
512
@@ -500,14 +521,28 @@ def user_list_paginate(self, _limit, _guests, _deactivated,
500
521
_user_id (string): Fully qualified Matrix user ID to search for.
501
522
_from (string): Offsets user list by this number, used for
502
523
pagination.
524
+ order_by (string or None): Method of sorting returned users. See
525
+ Synapse's documentation for valid choices. None uses Synapse
526
+ defaults. Note that methods other than "name" or
527
+ "creation_ts" may be slow and cause a major load as they
528
+ have no database index.
529
+ _dir (string or None): Direction of sorting. "f" for forwards
530
+ (default or when None), "b" for backwards/reversed.
531
+ not_user_type (string or list or None): User type to exclude.
532
+ Supports list for multiple values. Possible values are
533
+ "bot", "support", or "" (to exclude users without a user
534
+ type). Defaults to None for no filtering.
535
+ locked (bool): Include locked users. Defaults to not
536
+ including them.
503
537
504
538
Yields:
505
539
dict: The Admin API response for listing accounts.
506
540
https://element-hq.github.io/synapse/latest/admin_api/user_admin_api.html#list-accounts
507
541
"""
508
542
while _from is not None :
509
543
response = self .user_list (_from , _limit , _guests , _deactivated ,
510
- _name , _user_id , admin )
544
+ _name , _user_id , admin , order_by ,
545
+ _dir , not_user_type , locked )
511
546
yield response
512
547
_from = response .get ("next_token" , None )
513
548
0 commit comments