From 8a1fb2dcd6f35f5d279a4753f8be8ede04fa5bcc Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Thu, 6 Feb 2020 14:15:53 +0000 Subject: [PATCH] presence: Calculate server_timestamp slightly earlier. We want to err on the side of server_timestamp being old, since we may eventually use this to make responses just include incremental changes, and we don't want a time window (however small) when we miss presence rows. The clients will be able to deal with duplicate data to the extent that the time windows are overlapping. Also, extracting the other local var here (for `presences`) will set up a subsequent commit where we re-format the data for clients with slim_presence=True. --- zerver/views/presence.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/zerver/views/presence.py b/zerver/views/presence.py index 2bb21b2676..e4ccb66d9c 100644 --- a/zerver/views/presence.py +++ b/zerver/views/presence.py @@ -23,8 +23,9 @@ from zerver.models import UserActivity, UserPresence, UserProfile, \ def get_status_list(requesting_user_profile: UserProfile, slim_presence: bool) -> Dict[str, Any]: - return {'presences': get_status_dict(requesting_user_profile, slim_presence), - 'server_timestamp': time.time()} + server_timestamp = time.time() + presences = get_status_dict(requesting_user_profile, slim_presence) + return dict(presences=presences, server_timestamp=server_timestamp) def get_presence_backend(request: HttpRequest, user_profile: UserProfile, email: str) -> HttpResponse: