Skip to content

Commit

Permalink
Use update_membership for profile updates
Browse files Browse the repository at this point in the history
  • Loading branch information
illicitonion committed Feb 15, 2016
1 parent 1bbb67c commit 8168341
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
28 changes: 12 additions & 16 deletions synapse/handlers/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -208,21 +207,18 @@ def _update_join_states(self, user):
)

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",
Expand Down
4 changes: 0 additions & 4 deletions synapse/handlers/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@
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,
Expand Down

0 comments on commit 8168341

Please sign in to comment.