summary refs log tree commit diff
path: root/synapse/push
diff options
context:
space:
mode:
Diffstat (limited to 'synapse/push')
-rw-r--r--synapse/push/__init__.py13
-rw-r--r--synapse/push/httppusher.py16
2 files changed, 26 insertions, 3 deletions
diff --git a/synapse/push/__init__.py b/synapse/push/__init__.py
index 9cf996fb80..5f4e833add 100644
--- a/synapse/push/__init__.py
+++ b/synapse/push/__init__.py
@@ -62,6 +62,19 @@ class Pusher(object):
         return True
 
     @defer.inlineCallbacks
+    def get_context_for_event(self, ev):
+        name_aliases = yield self.store.get_room_name_and_aliases(
+            ev['room_id']
+        )
+
+        ctx = {'aliases': name_aliases[1]}
+        if name_aliases[0] is not None:
+            ctx['name'] = name_aliases[0]
+
+        defer.returnValue(ctx)
+
+
+    @defer.inlineCallbacks
     def start(self):
         if not self.last_token:
             # First-time setup: get a token to start from (we can't
diff --git a/synapse/push/httppusher.py b/synapse/push/httppusher.py
index bcfa06e2ab..7631a741fa 100644
--- a/synapse/push/httppusher.py
+++ b/synapse/push/httppusher.py
@@ -50,6 +50,7 @@ class HttpPusher(Pusher):
         self.data_minus_url.update(self.data)
         del self.data_minus_url['url']
 
+    @defer.inlineCallbacks
     def _build_notification_dict(self, event):
         # we probably do not want to push for every presence update
         # (we may want to be able to set up notifications when specific
@@ -57,9 +58,11 @@ class HttpPusher(Pusher):
         # Actually, presence events will not get this far now because we
         # need to filter them out in the main Pusher code.
         if 'event_id' not in event:
-            return None
+            defer.returnValue(None)
+
+        ctx = yield self.get_context_for_event(event)
 
-        return {
+        d = {
             'notification': {
                 'transition': 'new',
                 # everything is new for now: we don't have read receipts
@@ -85,9 +88,16 @@ class HttpPusher(Pusher):
             }
         }
 
+        if len(ctx['aliases']):
+            d['notification']['roomAlias'] = ctx['aliases'][0]
+        if 'name' in ctx:
+            d['notification']['roomName'] = ctx['name']
+
+        defer.returnValue(d)
+
     @defer.inlineCallbacks
     def dispatch_push(self, event):
-        notification_dict = self._build_notification_dict(event)
+        notification_dict = yield self._build_notification_dict(event)
         if not notification_dict:
             defer.returnValue([])
         try: