summary refs log tree commit diff
path: root/synapse/push/mailer.py
diff options
context:
space:
mode:
authorDavid Baker <dave@matrix.org>2016-04-27 17:50:49 +0100
committerDavid Baker <dave@matrix.org>2016-04-27 17:50:49 +0100
commit424a7f48f8d5cdb97ec3567d6841cecbf65ffda2 (patch)
tree24c7be8cdcd3a88d6913fd5d2e72593e797563e6 /synapse/push/mailer.py
parentMake html messages work (diff)
downloadsynapse-424a7f48f8d5cdb97ec3567d6841cecbf65ffda2.tar.xz
Run filter_events_for_client
so we don't accidentally mail out events people shouldn't see
Diffstat (limited to '')
-rw-r--r--synapse/push/mailer.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/synapse/push/mailer.py b/synapse/push/mailer.py
index a4a0891e05..afdf439664 100644
--- a/synapse/push/mailer.py
+++ b/synapse/push/mailer.py
@@ -155,13 +155,15 @@ class Mailer(object):
         }
 
         for n in notifs:
-            vars = yield self.get_notif_vars(n, notif_events[n['event_id']], room_state)
+            vars = yield self.get_notif_vars(
+                n, user_id, notif_events[n['event_id']], room_state
+            )
             room_vars['notifs'].append(vars)
 
         defer.returnValue(room_vars)
 
     @defer.inlineCallbacks
-    def get_notif_vars(self, notif, notif_event, room_state):
+    def get_notif_vars(self, notif, user_id, notif_event, room_state):
         results = yield self.store.get_events_around(
             notif['room_id'], notif['event_id'],
             before_limit=CONTEXT_BEFORE, after_limit=0
@@ -173,15 +175,17 @@ class Mailer(object):
             "messages": [],
         }
 
-        for event in results['events_before']:
+        handler = self.hs.get_handlers().message_handler
+        the_events = yield handler.filter_events_for_client(
+            user_id, results["events_before"]
+        )
+        the_events.append(notif_event)
+
+        for event in the_events:
             vars = self.get_message_vars(notif, event, room_state)
             if vars is not None:
                 ret['messages'].append(vars)
 
-        vars = self.get_message_vars(notif, notif_event, room_state)
-        if vars is not None:
-            ret['messages'].append(vars)
-
         defer.returnValue(ret)
 
     def get_message_vars(self, notif, event, room_state):