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.
This commit is contained in:
Steve Howell 2020-02-06 14:15:53 +00:00 committed by Tim Abbott
parent 14e0322dda
commit 8a1fb2dcd6

View File

@ -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: