summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorAlexander Fechler <141915399+afechler@users.noreply.github.com>2023-08-18 13:26:38 +0200
committerGitHub <noreply@github.com>2023-08-18 12:26:38 +0100
commit54317d34b76adb1e8f694acd91f631b3abe38947 (patch)
tree172fedb2e2460e569abf0a7ea5cc4e101954ae31 /synapse/storage
parentAdd response time metrics for introspection requests (#16131) (diff)
downloadsynapse-54317d34b76adb1e8f694acd91f631b3abe38947.tar.xz
Allow filtering for admins in the list accounts admin API (#16114)
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/databases/main/__init__.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/synapse/storage/databases/main/__init__.py b/synapse/storage/databases/main/__init__.py
index be67d1ff22..e17f25e87a 100644
--- a/synapse/storage/databases/main/__init__.py
+++ b/synapse/storage/databases/main/__init__.py
@@ -168,6 +168,7 @@ class DataStore(
         name: Optional[str] = None,
         guests: bool = True,
         deactivated: bool = False,
+        admins: Optional[bool] = None,
         order_by: str = UserSortOrder.NAME.value,
         direction: Direction = Direction.FORWARDS,
         approved: bool = True,
@@ -184,6 +185,9 @@ class DataStore(
             name: search for local part of user_id or display name
             guests: whether to in include guest users
             deactivated: whether to include deactivated users
+            admins: Optional flag to filter admins. If true, only admins are queried.
+                    if false, admins are excluded from the query. When it is
+                    none (the default), both admins and none-admins are queried.
             order_by: the sort order of the returned list
             direction: sort ascending or descending
             approved: whether to include approved users
@@ -220,6 +224,12 @@ class DataStore(
             if not deactivated:
                 filters.append("deactivated = 0")
 
+            if admins is not None:
+                if admins:
+                    filters.append("admin = 1")
+                else:
+                    filters.append("admin = 0")
+
             if not approved:
                 # We ignore NULL values for the approved flag because these should only
                 # be already existing users that we consider as already approved.