@@ -171,6 +171,8 @@ def __init__(self, controller: Any) -> None:
171
171
self .server_version = self .initial_data ["zulip_version" ]
172
172
self .server_feature_level : int = self .initial_data .get ("zulip_feature_level" , 0 )
173
173
174
+ self ._store_server_presence_intervals ()
175
+
174
176
self .user_dict : Dict [str , MinimalUserData ] = {}
175
177
self .user_id_email_dict : Dict [int , str ] = {}
176
178
self ._all_users_by_id : Dict [int , RealmUser ] = {}
@@ -444,7 +446,7 @@ def _start_presence_updates(self) -> None:
444
446
view = self .controller .view
445
447
view .users_view .update_user_list (user_list = self .users )
446
448
view .middle_column .update_message_list_status_markers ()
447
- time .sleep (PRESENCE_PING_INTERVAL_SECS )
449
+ time .sleep (self . server_presence_ping_interval_secs )
448
450
449
451
@asynch
450
452
def toggle_message_reaction (
@@ -813,6 +815,18 @@ def _store_typing_duration_settings(self) -> None:
813
815
TYPING_STARTED_EXPIRY_PERIOD ,
814
816
)
815
817
818
+ def _store_server_presence_intervals (self ) -> None :
819
+ """
820
+ In ZFL 164, these values were added to the register response.
821
+ Uses default values if not received.
822
+ """
823
+ self .server_presence_offline_threshold_secs = self .initial_data .get (
824
+ "server_presence_offline_threshold_seconds" , PRESENCE_OFFLINE_THRESHOLD_SECS
825
+ )
826
+ self .server_presence_ping_interval_secs = self .initial_data .get (
827
+ "server_presence_ping_interval_seconds" , PRESENCE_PING_INTERVAL_SECS
828
+ )
829
+
816
830
@staticmethod
817
831
def modernize_message_response (message : Message ) -> Message :
818
832
"""
@@ -1201,7 +1215,7 @@ def _update_users_data_from_initial_data(self) -> None:
1201
1215
*
1202
1216
* Out of the ClientPresence objects found in `presence`, we
1203
1217
* consider only those with a timestamp newer than
1204
- * PRESENCE_OFFLINE_THRESHOLD_SECS ; then of
1218
+ * self.server_presence_offline_threshold_secs ; then of
1205
1219
* those, return the one that has the greatest UserStatus, where
1206
1220
* `active` > `idle` > `offline`.
1207
1221
*
@@ -1215,7 +1229,9 @@ def _update_users_data_from_initial_data(self) -> None:
1215
1229
timestamp = client [1 ]["timestamp" ]
1216
1230
if client_name == "aggregated" :
1217
1231
continue
1218
- elif (time .time () - timestamp ) < PRESENCE_OFFLINE_THRESHOLD_SECS :
1232
+ elif (
1233
+ time .time () - timestamp
1234
+ ) < self .server_presence_offline_threshold_secs :
1219
1235
if status == "active" :
1220
1236
aggregate_status = "active"
1221
1237
if status == "idle" and aggregate_status != "active" :
0 commit comments