summary refs log tree commit diff
path: root/synapse/handlers/room.py
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-12-02 10:40:22 +0000
committerMark Haines <mark.haines@matrix.org>2015-12-02 10:40:22 +0000
commit2a0ec3b89d6b97e8a91ef5320d5e6675acacffdd (patch)
treebc022d01b40c2fdc701d4e1183931217cb6dfd6f /synapse/handlers/room.py
parentOnly fire user_joined_room if the membership has changed (diff)
parentMerge pull request #409 from MadsRC/develop (diff)
downloadsynapse-2a0ec3b89d6b97e8a91ef5320d5e6675acacffdd.tar.xz
Merge branch 'develop' into markjh/edu_frequency
Conflicts:
	synapse/handlers/federation.py
	synapse/handlers/room.py
Diffstat (limited to 'synapse/handlers/room.py')
-rw-r--r--synapse/handlers/room.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py
index cb6ac37758..1e18038e15 100644
--- a/synapse/handlers/room.py
+++ b/synapse/handlers/room.py
@@ -41,6 +41,18 @@ logger = logging.getLogger(__name__)
 id_server_scheme = "https://"
 
 
+def collect_presencelike_data(distributor, user, content):
+    return distributor.fire("collect_presencelike_data", user, content)
+
+
+def user_left_room(distributor, user, room_id):
+    return distributor.fire("user_left_room", user=user, room_id=room_id)
+
+
+def user_joined_room(distributor, user, room_id):
+    return distributor.fire("user_joined_room", user=user, room_id=room_id)
+
+
 class RoomCreationHandler(BaseHandler):
 
     PRESETS_DICT = {
@@ -438,9 +450,7 @@ class RoomMemberHandler(BaseHandler):
 
             if prev_state and prev_state.membership == Membership.JOIN:
                 user = UserID.from_string(event.user_id)
-                self.distributor.fire(
-                    "user_left_room", user=user, room_id=event.room_id
-                )
+                user_left_room(self.distributor, user, event.room_id)
 
         defer.returnValue({"room_id": room_id})
 
@@ -458,9 +468,7 @@ class RoomMemberHandler(BaseHandler):
             raise SynapseError(404, "No known servers")
 
         # If event doesn't include a display name, add one.
-        yield self.distributor.fire(
-            "collect_presencelike_data", joinee, content
-        )
+        yield collect_presencelike_data(self.distributor, joinee, content)
 
         content.update({"membership": Membership.JOIN})
         builder = self.event_builder_factory.new({
@@ -520,9 +528,7 @@ class RoomMemberHandler(BaseHandler):
         prev_state = context.current_state.get((event.type, event.state_key))
         if not prev_state or prev_state.membership != Membership.JOIN:
             user = UserID.from_string(event.user_id)
-            yield self.distributor.fire(
-                "user_joined_room", user=user, room_id=room_id
-            )
+            yield user_joined_room(self.distributor, user, room_id)
 
     @defer.inlineCallbacks
     def get_inviter(self, event):