def identify_request(request: RequestType):
    """Try to identify whether this is a Diaspora request.

    Try first public message. Then private message. The check if this is a legacy payload.
    """
    # Private encrypted JSON payload
    try:
        data = json.loads(decode_if_bytes(request.body))
        if "encrypted_magic_envelope" in data:
            return True
    except Exception:
        pass
    # Public XML payload
    try:
        xml = etree.fromstring(encode_if_text(request.body))
        if xml.tag == MAGIC_ENV_TAG:
            return True
    except Exception:
        pass
    return False
def identify_request ( request : RequestType ) : try : data = json . loads ( decode_if_bytes ( request . body ) ) if "encrypted_magic_envelope" in data : return True except Exception : pass try : xml = etree . fromstring ( encode_if_text ( request . body ) ) if xml . tag == MAGIC_ENV_TAG : return True except Exception : pass return False
Try to identify whether this is a Diaspora request.

    Try first public message. Then private message. The check if this is a legacy payload.