summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
Diffstat (limited to 'synapse')
-rw-r--r--synapse/handlers/_base.py2
-rw-r--r--synapse/handlers/message.py8
-rw-r--r--synapse/handlers/room.py2
-rw-r--r--synapse/handlers/search.py8
-rw-r--r--synapse/handlers/sync.py4
-rw-r--r--synapse/notifier.py2
-rw-r--r--synapse/push/mailer.py18
7 files changed, 24 insertions, 20 deletions
diff --git a/synapse/handlers/_base.py b/synapse/handlers/_base.py
index 13a675b208..134729069a 100644
--- a/synapse/handlers/_base.py
+++ b/synapse/handlers/_base.py
@@ -192,7 +192,7 @@ class BaseHandler(object):
         })
 
     @defer.inlineCallbacks
-    def _filter_events_for_client(self, user_id, events, is_peeking=False):
+    def filter_events_for_client(self, user_id, events, is_peeking=False):
         """
         Check which events a user is allowed to see
 
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py
index f51feda2f4..7d9e3cf364 100644
--- a/synapse/handlers/message.py
+++ b/synapse/handlers/message.py
@@ -123,7 +123,7 @@ class MessageHandler(BaseHandler):
                 "end": next_token.to_string(),
             })
 
-        events = yield self._filter_events_for_client(
+        events = yield self.filter_events_for_client(
             user_id,
             events,
             is_peeking=(member_event_id is None),
@@ -483,7 +483,7 @@ class MessageHandler(BaseHandler):
                     ]
                 ).addErrback(unwrapFirstError)
 
-                messages = yield self._filter_events_for_client(
+                messages = yield self.filter_events_for_client(
                     user_id, messages
                 )
 
@@ -619,7 +619,7 @@ class MessageHandler(BaseHandler):
             end_token=stream_token
         )
 
-        messages = yield self._filter_events_for_client(
+        messages = yield self.filter_events_for_client(
             user_id, messages, is_peeking=is_peeking
         )
 
@@ -700,7 +700,7 @@ class MessageHandler(BaseHandler):
             consumeErrors=True,
         ).addErrback(unwrapFirstError)
 
-        messages = yield self._filter_events_for_client(
+        messages = yield self.filter_events_for_client(
             user_id, messages, is_peeking=is_peeking,
         )
 
diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py
index dd9c18df84..fdebc9c438 100644
--- a/synapse/handlers/room.py
+++ b/synapse/handlers/room.py
@@ -449,7 +449,7 @@ class RoomContextHandler(BaseHandler):
         now_token = yield self.hs.get_event_sources().get_current_token()
 
         def filter_evts(events):
-            return self._filter_events_for_client(
+            return self.filter_events_for_client(
                 user.to_string(),
                 events,
                 is_peeking=is_guest)
diff --git a/synapse/handlers/search.py b/synapse/handlers/search.py
index 9937d8dd7f..a937e87408 100644
--- a/synapse/handlers/search.py
+++ b/synapse/handlers/search.py
@@ -172,7 +172,7 @@ class SearchHandler(BaseHandler):
 
             filtered_events = search_filter.filter([r["event"] for r in results])
 
-            events = yield self._filter_events_for_client(
+            events = yield self.filter_events_for_client(
                 user.to_string(), filtered_events
             )
 
@@ -223,7 +223,7 @@ class SearchHandler(BaseHandler):
                     r["event"] for r in results
                 ])
 
-                events = yield self._filter_events_for_client(
+                events = yield self.filter_events_for_client(
                     user.to_string(), filtered_events
                 )
 
@@ -281,11 +281,11 @@ class SearchHandler(BaseHandler):
                     event.room_id, event.event_id, before_limit, after_limit
                 )
 
-                res["events_before"] = yield self._filter_events_for_client(
+                res["events_before"] = yield self.filter_events_for_client(
                     user.to_string(), res["events_before"]
                 )
 
-                res["events_after"] = yield self._filter_events_for_client(
+                res["events_after"] = yield self.filter_events_for_client(
                     user.to_string(), res["events_after"]
                 )
 
diff --git a/synapse/handlers/sync.py b/synapse/handlers/sync.py
index 231140b655..b51bb651ec 100644
--- a/synapse/handlers/sync.py
+++ b/synapse/handlers/sync.py
@@ -681,7 +681,7 @@ class SyncHandler(BaseHandler):
 
             if recents is not None:
                 recents = sync_config.filter_collection.filter_room_timeline(recents)
-                recents = yield self._filter_events_for_client(
+                recents = yield self.filter_events_for_client(
                     sync_config.user.to_string(),
                     recents,
                 )
@@ -702,7 +702,7 @@ class SyncHandler(BaseHandler):
                 loaded_recents = sync_config.filter_collection.filter_room_timeline(
                     events
                 )
-                loaded_recents = yield self._filter_events_for_client(
+                loaded_recents = yield self.filter_events_for_client(
                     sync_config.user.to_string(),
                     loaded_recents,
                 )
diff --git a/synapse/notifier.py b/synapse/notifier.py
index 6af7a8f424..cb58dfffd4 100644
--- a/synapse/notifier.py
+++ b/synapse/notifier.py
@@ -399,7 +399,7 @@ class Notifier(object):
 
                 if name == "room":
                     room_member_handler = self.hs.get_handlers().room_member_handler
-                    new_events = yield room_member_handler._filter_events_for_client(
+                    new_events = yield room_member_handler.filter_events_for_client(
                         user.to_string(),
                         new_events,
                         is_peeking=is_peeking,
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):