summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorDaniel Wagner-Hall <daniel@matrix.org>2016-02-15 17:14:34 +0000
committerDaniel Wagner-Hall <daniel@matrix.org>2016-02-15 17:14:34 +0000
commit8168341e9bf8aa3c29b3fde9af12df0f1839baf1 (patch)
tree9aaeba45df78327fd7f026422fe4675e41077d92 /synapse
parentUse update_membership to kick guests (diff)
downloadsynapse-8168341e9bf8aa3c29b3fde9af12df0f1839baf1.tar.xz
Use update_membership for profile updates
Diffstat (limited to '')
-rw-r--r--synapse/handlers/profile.py28
-rw-r--r--synapse/handlers/room.py4
2 files changed, 12 insertions, 20 deletions
diff --git a/synapse/handlers/profile.py b/synapse/handlers/profile.py
index 629e6e3594..2850db4a1f 100644
--- a/synapse/handlers/profile.py
+++ b/synapse/handlers/profile.py
@@ -16,8 +16,7 @@
 from twisted.internet import defer
 
 from synapse.api.errors import SynapseError, AuthError, CodeMessageException
-from synapse.api.constants import EventTypes, Membership
-from synapse.types import UserID
+from synapse.types import UserID, Requester
 from synapse.util import unwrapFirstError
 
 from ._base import BaseHandler
@@ -208,21 +207,18 @@ class ProfileHandler(BaseHandler):
         )
 
         for j in joins:
-            content = {
-                "membership": Membership.JOIN,
-            }
-
-            yield collect_presencelike_data(self.distributor, user, content)
-
-            msg_handler = self.hs.get_handlers().message_handler
+            handler = self.hs.get_handlers().room_member_handler
             try:
-                yield msg_handler.create_and_send_event({
-                    "type": EventTypes.Member,
-                    "room_id": j.room_id,
-                    "state_key": user.to_string(),
-                    "content": content,
-                    "sender": user.to_string()
-                }, ratelimit=False)
+                # Assume the user isn't a guest because we don't let guests set
+                # profile or avatar data.
+                requester = Requester(user, "", False)
+                yield handler.update_membership(
+                    requester,
+                    user,
+                    j.room_id,
+                    "join",  # We treat a profile update like a join.
+                    ratelimit=False,
+                )
             except Exception as e:
                 logger.warn(
                     "Failed to update join event for room %s - %s",
diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py
index 8c8bacf5dd..505fb383ec 100644
--- a/synapse/handlers/room.py
+++ b/synapse/handlers/room.py
@@ -41,10 +41,6 @@ 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 preserve_context_over_fn(
         distributor.fire,