summary refs log tree commit diff
path: root/synapse/api
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-01-25 10:10:44 +0000
committerErik Johnston <erik@matrix.org>2016-01-25 10:10:44 +0000
commit4021f95261ebdcca0ec2c3c91e8dd442a85c5ed4 (patch)
treebffe640c7934a01d6d69b2e6a00fb49361f6eefe /synapse/api
parentMerge branch 'develop' of github.com:matrix-org/synapse into erikj/sync (diff)
downloadsynapse-4021f95261ebdcca0ec2c3c91e8dd442a85c5ed4.tar.xz
Move logic from rest/ to handlers/
Diffstat (limited to 'synapse/api')
-rw-r--r--synapse/api/filtering.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/synapse/api/filtering.py b/synapse/api/filtering.py
index 5530b8c48f..116060ee7f 100644
--- a/synapse/api/filtering.py
+++ b/synapse/api/filtering.py
@@ -190,18 +190,16 @@ class Filter(object):
         Returns:
             bool: True if the event matches
         """
-        if isinstance(event, dict):
-            return self.check_fields(
-                event.get("room_id", None),
-                event.get("sender", None),
-                event.get("type", None),
-            )
-        else:
-            return self.check_fields(
-                getattr(event, "room_id", None),
-                getattr(event, "sender", None),
-                event.type,
-            )
+        sender = event.get("sender", None)
+        if not sender:
+            # Presence events have their 'sender' in content.user_id
+            sender = event.get("conntent", {}).get("user_id", None)
+
+        return self.check_fields(
+            event.get("room_id", None),
+            sender,
+            event.get("type", None),
+        )
 
     def check_fields(self, room_id, sender, event_type):
         """Checks whether the filter matches the given event fields.