summary refs log tree commit diff
path: root/synapse/push
diff options
context:
space:
mode:
authorDavid Baker <dave@matrix.org>2015-01-29 18:51:22 +0000
committerDavid Baker <dave@matrix.org>2015-01-29 18:51:22 +0000
commit0b1688639750e2401571263c127817d0b0a43644 (patch)
tree5e058f035604cef930cc29a53e21fe76dcd16ea6 /synapse/push
parentAdd default push rules including setting a sound for messages mentioning your... (diff)
downloadsynapse-0b1688639750e2401571263c127817d0b0a43644.tar.xz
Change 'from' in notification pokes to 'sender' to match client API v2. Send sender display names where they exist.
Diffstat (limited to 'synapse/push')
-rw-r--r--synapse/push/__init__.py10
-rw-r--r--synapse/push/httppusher.py9
2 files changed, 14 insertions, 5 deletions
diff --git a/synapse/push/__init__.py b/synapse/push/__init__.py
index d19e13d644..19478c72a2 100644
--- a/synapse/push/__init__.py
+++ b/synapse/push/__init__.py
@@ -154,6 +154,16 @@ class Pusher(object):
         if name_aliases[0] is not None:
             ctx['name'] = name_aliases[0]
 
+        their_member_events_for_room = yield self.store.get_current_state(
+            room_id=ev['room_id'],
+            event_type='m.room.member',
+            state_key=ev['user_id']
+        )
+        if len(their_member_events_for_room) > 0:
+            dn = their_member_events_for_room[0].content['displayname']
+            if dn is not None:
+                ctx['sender_display_name'] = dn
+
         defer.returnValue(ctx)
 
     @defer.inlineCallbacks
diff --git a/synapse/push/httppusher.py b/synapse/push/httppusher.py
index ab128e31e5..ac7c3148d7 100644
--- a/synapse/push/httppusher.py
+++ b/synapse/push/httppusher.py
@@ -67,10 +67,7 @@ class HttpPusher(Pusher):
             'notification': {
                 'id': event['event_id'],
                 'type': event['type'],
-                'from': event['user_id'],
-                # we may have to fetch this over federation and we
-                # can't trust it anyway: is it worth it?
-                #'from_display_name': 'Steve Stevington'
+                'sender': event['user_id'],
                 'counts': {  # -- we don't mark messages as read yet so
                              # we have no way of knowing
                     # Just set the badge to 1 until we have read receipts
@@ -93,6 +90,8 @@ class HttpPusher(Pusher):
 
         if len(ctx['aliases']):
             d['notification']['room_alias'] = ctx['aliases'][0]
+        if 'sender_display_name' in ctx:
+            d['notification']['sender_display_name'] = ctx['sender_display_name']
         if 'name' in ctx:
             d['notification']['room_name'] = ctx['name']
 
@@ -119,7 +118,7 @@ class HttpPusher(Pusher):
             'notification': {
                 'id': '',
                 'type': None,
-                'from': '',
+                'sender': '',
                 'counts': {
                     'unread': 0,
                     'missed_calls': 0