diff options
author | Brendan Abolivier <babolivier@matrix.org> | 2021-03-18 18:37:19 +0100 |
---|---|---|
committer | Brendan Abolivier <babolivier@matrix.org> | 2021-03-18 18:37:19 +0100 |
commit | 066c703729d72b5da8bb6574d7f7f5f13e12f773 (patch) | |
tree | ae94a3107441cb06b3d26c6811381470ed27fe22 /synapse/handlers/presence.py | |
parent | Implement MSC3026: busy presence state (diff) | |
download | synapse-066c703729d72b5da8bb6574d7f7f5f13e12f773.tar.xz |
Move support for MSC3026 behind an experimental flag
Diffstat (limited to 'synapse/handlers/presence.py')
-rw-r--r-- | synapse/handlers/presence.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py index bcb99f627b..372017590d 100644 --- a/synapse/handlers/presence.py +++ b/synapse/handlers/presence.py @@ -104,6 +104,8 @@ class BasePresenceHandler(abc.ABC): self.clock = hs.get_clock() self.store = hs.get_datastore() + self._busy_presence_enabled = hs.config.experimental.msc3026_enabled + active_presence = self.store.take_presence_startup_info() self.user_to_current_state = {state.user_id: state for state in active_presence} @@ -730,8 +732,11 @@ 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: raise SynapseError(400, "Invalid presence state") @@ -745,7 +750,10 @@ class PresenceHandler(BasePresenceHandler): msg = status_msg if presence != PresenceState.OFFLINE else None new_fields["status_msg"] = msg - if presence == PresenceState.ONLINE or 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() await self._update_states([prev_state.copy_and_replace(**new_fields)]) |