diff options
author | Mark Haines <mjark@negativecurvature.net> | 2015-01-26 16:23:48 +0000 |
---|---|---|
committer | Mark Haines <mjark@negativecurvature.net> | 2015-01-26 16:23:48 +0000 |
commit | 9b6aaf2074c6a47f673f91926a0ba9faf219e8ce (patch) | |
tree | 15e3c49e081f0182a4ef278afdd6d34695db5cc5 /synapse/events/utils.py | |
parent | Create (empty) v2_alpha REST tests directory (diff) | |
parent | Remove unused import from server.py (diff) | |
download | synapse-9b6aaf2074c6a47f673f91926a0ba9faf219e8ce.tar.xz |
Merge pull request #34 from matrix-org/remove_serialize_event_from_hs
Don't pass the HS to serialize_event just so that it can get the current time.
Diffstat (limited to 'synapse/events/utils.py')
-rw-r--r-- | synapse/events/utils.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/synapse/events/utils.py b/synapse/events/utils.py index bcb5457278..e391aca4cc 100644 --- a/synapse/events/utils.py +++ b/synapse/events/utils.py @@ -89,31 +89,31 @@ def prune_event(event): return type(event)(allowed_fields) -def serialize_event(hs, e, client_event=True): +def serialize_event(e, time_now_ms, client_event=True): # FIXME(erikj): To handle the case of presence events and the like if not isinstance(e, EventBase): return e + time_now_ms = int(time_now_ms) + # Should this strip out None's? d = {k: v for k, v in e.get_dict().items()} if not client_event: # set the age and keep all other keys if "age_ts" in d["unsigned"]: - now = int(hs.get_clock().time_msec()) - d["unsigned"]["age"] = now - d["unsigned"]["age_ts"] + d["unsigned"]["age"] = time_now_ms - d["unsigned"]["age_ts"] return d if "age_ts" in d["unsigned"]: - now = int(hs.get_clock().time_msec()) - d["age"] = now - d["unsigned"]["age_ts"] + d["age"] = time_now_ms - d["unsigned"]["age_ts"] del d["unsigned"]["age_ts"] d["user_id"] = d.pop("sender", None) if "redacted_because" in e.unsigned: d["redacted_because"] = serialize_event( - hs, e.unsigned["redacted_because"] + e.unsigned["redacted_because"], time_now_ms ) del d["unsigned"]["redacted_because"] |