From ee3df06183cbebfe04f51cdd3a1a85a6b50efa9a Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Mon, 8 Dec 2014 14:50:48 +0000 Subject: More bug fixes --- synapse/federation/replication.py | 2 +- synapse/handlers/_base.py | 4 ---- synapse/handlers/message.py | 12 ++++++++++++ synapse/handlers/room.py | 7 +------ synapse/state.py | 8 ++++++-- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/synapse/federation/replication.py b/synapse/federation/replication.py index 3af24ee46d..d4cd79b7ac 100644 --- a/synapse/federation/replication.py +++ b/synapse/federation/replication.py @@ -713,7 +713,7 @@ class _TransactionQueue(object): # table and we'll get back to it later. destinations = set(destinations) - destinations.remove(self.server_name) + destinations.discard(self.server_name) logger.debug("Sending to: %s", str(destinations)) diff --git a/synapse/handlers/_base.py b/synapse/handlers/_base.py index 871564a3a2..4cbc0c027c 100644 --- a/synapse/handlers/_base.py +++ b/synapse/handlers/_base.py @@ -88,10 +88,6 @@ class BaseHandler(object): prev_state = ret if builder.is_state(): - prev_state = yield self.store.add_event_hashes( - prev_state - ) - builder.prev_state = prev_state yield self.auth.add_auth_events(builder, context) diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py index 485d8e8179..8ee560d79a 100644 --- a/synapse/handlers/message.py +++ b/synapse/handlers/message.py @@ -137,6 +137,18 @@ class MessageHandler(BaseHandler): def handle_event(self, event_dict): builder = self.event_builder_factory.new(event_dict) + + if builder.type == EventTypes.Member: + membership = builder.content.get("membership", None) + if membership == Membership.JOIN: + joinee = self.hs.parse_userid(builder.state_key) + # If event doesn't include a display name, add one. + yield self.distributor.fire( + "collect_presencelike_data", + joinee, + builder.content + ) + event, context = yield self._create_new_client_event( builder=builder, ) diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py index ffcdbcfdf7..4f4b275290 100644 --- a/synapse/handlers/room.py +++ b/synapse/handlers/room.py @@ -187,6 +187,7 @@ class RoomCreationHandler(BaseHandler): creation_event = create( etype=RoomCreateEvent.TYPE, content={"creator": creator.to_string()}, + state_key="", ) join_event = create( @@ -406,11 +407,6 @@ class RoomMemberHandler(BaseHandler): # room_id = RoomID.from_string(event.room_id, self.hs) room_id = event.room_id - # If event doesn't include a display name, add one. - yield self.distributor.fire( - "collect_presencelike_data", joinee, event.content - ) - # XXX: We don't do an auth check if we are doing an invite # join dance for now, since we're kinda implicitly checking # that we are allowed to join when we decide whether or not we @@ -524,7 +520,6 @@ class RoomMemberHandler(BaseHandler): context, extra_users=[target_user], suppress_auth=(not do_auth), - do_invite_host=do_invite_host, ) diff --git a/synapse/state.py b/synapse/state.py index 464cbae564..19b408db45 100644 --- a/synapse/state.py +++ b/synapse/state.py @@ -149,7 +149,7 @@ class StateHandler(object): if event.is_state(): ret = yield self.resolve_state_groups( [e for e, _ in event.prev_events], - event_type=event.event_type, + event_type=event.type, state_key=event.state_key, ) else: @@ -200,7 +200,11 @@ class StateHandler(object): prev_state = state.get((event_type, state_key), None) if prev_state: prev_state = prev_state.event_id - defer.returnValue((name, state, [prev_state])) + prev_states = [prev_state] + else: + prev_states = [] + + defer.returnValue((name, state, prev_states)) state = {} for group, g_state in state_groups.items(): -- cgit 1.4.1