'Called with the state deltas to process'

@defer.inlineCallbacks
def _handle_deltas(self, deltas):

    for delta in deltas:
        typ = delta['type']
        state_key = delta['state_key']
        room_id = delta['room_id']
        event_id = delta['event_id']
        prev_event_id = delta['prev_event_id']
        logger.debug('Handling:    %r    %r,    %s', typ, state_key, event_id)
        if (typ in (EventTypes.RoomHistoryVisibility, EventTypes.JoinRules)):
            (yield self._handle_room_publicity_change(room_id, prev_event_id, event_id, typ))
        elif (typ == EventTypes.Member):
            change = (yield self._get_key_change(prev_event_id, event_id, key_name='membership', public_value=Membership.JOIN))
            if (change is None):
                (yield self._handle_profile_change(state_key, room_id, prev_event_id, event_id))
                continue
            if (not change):
                is_in_room = (yield self.store.is_host_joined(room_id, self.server_name))
                if (not is_in_room):
                    logger.info('Server    left    room:    %r', room_id)
                    user_ids = (yield self.store.get_users_in_dir_due_to_room(room_id))
                    for user_id in user_ids:
                        (yield self._handle_remove_user(room_id, user_id))
                    return
                else:
                    logger.debug('Server    is    still    in    room:    %r', room_id)
            if change:
                event = (yield self.store.get_event(event_id, allow_none=True))
                profile = ProfileInfo(avatar_url=event.content.get('avatar_url'), display_name=event.content.get('displayname'))
                (yield self._handle_new_user(room_id, state_key, profile))
            else:
                (yield self._handle_remove_user(room_id, state_key))
        else:
            logger.debug('Ignoring    irrelevant    type:    %r', typ)
