Skip to content

Commit

Permalink
allow appservice to be filtered by in users list
Browse files Browse the repository at this point in the history
  • Loading branch information
erulabs committed Aug 12, 2020
1 parent 39c3f68 commit 295a24e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion synapse/rest/admin/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ async def on_GET(self, request):
user_id = parse_string(request, "user_id", default=None)
guests = parse_boolean(request, "guests", default=True)
deactivated = parse_boolean(request, "deactivated", default=False)
appservice = parse_string(request, "appservice", default=False)

users, total = await self.store.get_users_paginate(
start, limit, user_id, guests, deactivated
start, limit, user_id, guests, deactivated, appservice
)
ret = {"users": users, "total": total}
if len(users) >= limit:
Expand Down
7 changes: 6 additions & 1 deletion synapse/storage/data_stores/main/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ def get_users(self):
)

def get_users_paginate(
self, start, limit, name=None, guests=True, deactivated=False
self, start, limit, name=None, guests=True, deactivated=False, appservice=False
):
"""Function to retrieve a paginated list of users from
users list. This will return a json list of users and the
Expand Down Expand Up @@ -526,6 +526,11 @@ def get_users_paginate_txn(txn):
if not deactivated:
filters.append("deactivated = 0")

if not appservice == False:
filters.append("appservice_id = ?")
args.append(appservice)


where_clause = "WHERE " + " AND ".join(filters) if len(filters) > 0 else ""

sql = "SELECT COUNT(*) as total_users FROM users %s" % (where_clause)
Expand Down

0 comments on commit 295a24e

Please sign in to comment.