api: Add server_timestamp to register response.

Since this is currently only useful to interpret presence data, we
send this only if presence is requested.

I'm not sure that server_timestamp is the right name for this field,
but ultimately it should match the main presence API format.
This commit is contained in:
Tim Abbott
2021-05-20 11:01:51 -07:00
committed by Tim Abbott
parent 637c7e297c
commit 2e67b879ed
10 changed files with 27 additions and 6 deletions

View File

@@ -1,6 +1,7 @@
# See https://zulip.readthedocs.io/en/latest/subsystems/events-system.html for
# high-level documentation on how this system works.
import copy
import time
from typing import Any, Callable, Collection, Dict, Iterable, Optional, Sequence, Set
from django.conf import settings
@@ -177,6 +178,8 @@ def fetch_initial_state_data(
state["presences"] = (
{} if user_profile is None else get_presences_for_realm(realm, slim_presence)
)
# Send server_timestamp, to match the format of `GET /presence` requests.
state["server_timestamp"] = time.time()
if want("realm"):
# The realm bundle includes both realm properties and server