def parse_boolean(request, name, default=None, required=False):
    """Parse a boolean parameter from the request query string

    :param request: the twisted HTTP request.
    :param name (str): the name of the query parameter.
    :param default: value to use if the parameter is absent, defaults to None.
    :param required (bool): whether to raise a 400 SynapseError if the
        parameter is absent, defaults to False.
    :return: A bool value or the default.
    :raises
        SynapseError if the parameter is absent and required, or if the
            parameter is present and not one of "true" or "false".
    """

    if request.args in name:
        try:
            return {
                "true": True,
                "false": False,
            }[request.args[name][0]]
        except:
            message = (
                "Boolean query parameter %r must be one of"
                " ['true', 'false']"
            ) % (name,)
            raise SynapseError(400, message)
    else:
        if required:
            message = "Missing boolean query parameter %r" % (name,)
            raise SynapseError(400, message, errcode=Codes.MISSING_PARAM)
        else:
            return default
dataset/ETHPy150Open matrix-org/synapse/synapse/http/servlet.py/parse_boolean/swapped operands of `in`