'Called (via the distributor) when a user joins a room. This funciton
sends presence updates to servers, either:
1. the joining user is a local user and we send their presence to
all servers in the room.
2. the joining user is a remote user and so we send presence for all
local users in the room.'

@defer.inlineCallbacks
def user_joined_room(self, user, room_id):

    if self.is_mine(user):
        state = (yield self.current_state_for_user(user.to_string()))
        self._push_to_remotes([state])
    else:
        user_ids = (yield self.store.get_users_in_room(room_id))
        user_ids = filter(self.is_mine_id, user_ids)
        states = (yield self.current_state_for_users(user_ids))
        self._push_to_remotes(states.values())
