'Check if the user was in the room at some point.
Args:
room_id(str): The room to check.
user_id(str): The user to check.
Raises:
AuthError if the user was never in the room.
Returns:
A deferred membership event for the user if the user was in the
room. This will be the join event if they are currently joined to
the room. This will be the leave event if they have left the room.'

@defer.inlineCallbacks
def check_user_was_in_room(self, room_id, user_id):

    member = (yield self.state.get_current_state(room_id=room_id, event_type=EventTypes.Member, state_key=user_id))
    membership = (member.membership if member else None)
    if (membership not in (Membership.JOIN, Membership.LEAVE)):
        raise AuthError(403, ('User    %s    not    in    room    %s' % (user_id, room_id)))
    if (membership == Membership.LEAVE):
        forgot = (yield self.store.did_forget(user_id, room_id))
        if forgot:
            raise AuthError(403, ('User    %s    not    in    room    %s' % (user_id, room_id)))
    defer.returnValue(member)
