summary refs log tree commit diff
path: root/synapse/notifier.py
diff options
context:
space:
mode:
authorErik Johnston <erikj@jki.re>2017-03-15 16:01:29 +0000
committerGitHub <noreply@github.com>2017-03-15 16:01:29 +0000
commit9d527191bcd14f51ae43cfccf18a34ecb19df801 (patch)
tree272a697640aaf3c919db0b63967908e89b8f16f5 /synapse/notifier.py
parentMerge pull request #1997 from matrix-org/dbkr/cas_partialdownload (diff)
parentComment (diff)
downloadsynapse-9d527191bcd14f51ae43cfccf18a34ecb19df801.tar.xz
Merge pull request #2013 from matrix-org/erikj/presence_FASTER
Format presence events on the edges instead of reformatting them multiple times
Diffstat (limited to 'synapse/notifier.py')
-rw-r--r--synapse/notifier.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/synapse/notifier.py b/synapse/notifier.py
index 2657dcd8dc..31f723d94d 100644
--- a/synapse/notifier.py
+++ b/synapse/notifier.py
@@ -16,6 +16,7 @@
 from twisted.internet import defer
 from synapse.api.constants import EventTypes, Membership
 from synapse.api.errors import AuthError
+from synapse.handlers.presence import format_user_presence_state
 
 from synapse.util import DeferredTimedOutError
 from synapse.util.logutils import log_function
@@ -412,6 +413,15 @@ class Notifier(object):
                         new_events,
                         is_peeking=is_peeking,
                     )
+                elif name == "presence":
+                    now = self.clock.time_msec()
+                    new_events[:] = [
+                        {
+                            "type": "m.presence",
+                            "content": format_user_presence_state(event, now),
+                        }
+                        for event in new_events
+                    ]
 
                 events.extend(new_events)
                 end_token = end_token.copy_and_replace(keyname, new_key)