summary refs log tree commit diff
path: root/synapse/storage/databases/main/registration.py
diff options
context:
space:
mode:
authorMathieu Velten <matmaul@gmail.com>2020-09-23 17:06:28 +0200
committerGitHub <noreply@github.com>2020-09-23 16:06:28 +0100
commit916bb9d0d15cf941e73b2e808c553a1edd1c2eb9 (patch)
tree9938653b43064cd6f66f6fb633f1f00cb24f1fd4 /synapse/storage/databases/main/registration.py
parentFix missing null character check on guest_access room state (#8373) (diff)
downloadsynapse-916bb9d0d15cf941e73b2e808c553a1edd1c2eb9.tar.xz
Don't push if an user account has expired (#8353)
Diffstat (limited to 'synapse/storage/databases/main/registration.py')
-rw-r--r--synapse/storage/databases/main/registration.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/synapse/storage/databases/main/registration.py b/synapse/storage/databases/main/registration.py
index 675e81fe34..33825e8949 100644
--- a/synapse/storage/databases/main/registration.py
+++ b/synapse/storage/databases/main/registration.py
@@ -116,6 +116,20 @@ class RegistrationWorkerStore(SQLBaseStore):
             desc="get_expiration_ts_for_user",
         )
 
+    async def is_account_expired(self, user_id: str, current_ts: int) -> bool:
+        """
+        Returns whether an user account is expired.
+
+        Args:
+            user_id: The user's ID
+            current_ts: The current timestamp
+
+        Returns:
+            Whether the user account has expired
+        """
+        expiration_ts = await self.get_expiration_ts_for_user(user_id)
+        return expiration_ts is not None and current_ts >= expiration_ts
+
     async def set_account_validity_for_user(
         self,
         user_id: str,