summary refs log tree commit diff
diff options
context:
space:
mode:
authorBrendan Abolivier <babolivier@matrix.org>2021-03-19 16:11:08 +0100
committerBrendan Abolivier <babolivier@matrix.org>2021-03-19 16:11:08 +0100
commit0b56481caafc56c2e624d4b6506c91fc3913615e (patch)
tree526530f2539181a6933f5b97ed36bfe6ac30f325
parentMove support for MSC3026 behind an experimental flag (diff)
downloadsynapse-0b56481caafc56c2e624d4b6506c91fc3913615e.tar.xz
Fix lint
Diffstat (limited to '')
-rw-r--r--synapse/app/generic_worker.py8
-rw-r--r--synapse/handlers/presence.py13
2 files changed, 10 insertions, 11 deletions
diff --git a/synapse/app/generic_worker.py b/synapse/app/generic_worker.py
index 207d5ccd02..caef394e1d 100644
--- a/synapse/app/generic_worker.py
+++ b/synapse/app/generic_worker.py
@@ -441,12 +441,12 @@ class GenericWorkerPresence(BasePresenceHandler):
             PresenceState.ONLINE,
             PresenceState.UNAVAILABLE,
             PresenceState.OFFLINE,
+            PresenceState.BUSY,
         )
 
-        if self._busy_presence_enabled:
-            valid_presence += (PresenceState.BUSY,)
-
-        if presence not in valid_presence:
+        if presence not in valid_presence or (
+            presence == PresenceState.BUSY and not self._busy_presence_enabled
+        ):
             raise SynapseError(400, "Invalid presence state")
 
         user_id = target_user.to_string()
diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py
index 372017590d..492c4478fa 100644
--- a/synapse/handlers/presence.py
+++ b/synapse/handlers/presence.py
@@ -732,12 +732,12 @@ class PresenceHandler(BasePresenceHandler):
             PresenceState.ONLINE,
             PresenceState.UNAVAILABLE,
             PresenceState.OFFLINE,
+            PresenceState.BUSY,
         )
 
-        if self._busy_presence_enabled:
-            valid_presence += (PresenceState.BUSY,)
-
-        if presence not in valid_presence:
+        if presence not in valid_presence or (
+            presence == PresenceState.BUSY and not self._busy_presence_enabled
+        ):
             raise SynapseError(400, "Invalid presence state")
 
         user_id = target_user.to_string()
@@ -750,9 +750,8 @@ class PresenceHandler(BasePresenceHandler):
             msg = status_msg if presence != PresenceState.OFFLINE else None
             new_fields["status_msg"] = msg
 
-        if (
-            presence == PresenceState.ONLINE or
-            (self._busy_presence_enabled and presence == PresenceState.BUSY)
+        if presence == PresenceState.ONLINE or (
+            self._busy_presence_enabled and presence == PresenceState.BUSY
         ):
             new_fields["last_active_ts"] = self.clock.time_msec()