Exemplo n.º 1
0
def join_mcserver(request, textures_host):
    username, server_hash, ip = request.args.get("username"), request.args.get(
        "serverId"), request.args.get("ip")
    if username is None or server_hash is None:
        # May be inconsistent with official API
        return NULL_MESSAGE.dual

    profile = Profile.get_profile_with_name(username)
    if profile is None:
        # May be inconsistent with official API
        return MCSERVER_INVALID_PROFILE.dual

    session = MCServerSession.get(
        lambda x: x.profile == profile and x.server_hash == server_hash)

    if session is None:
        # May be inconsistent with official API
        return MCSERVER_INVALID_SESSION.dual

    if ip is not None and session.client_side_ip != ip:
        # May be inconsistent with official API
        return MCSERVER_DIFFERENT_IP.dual

    session.delete()

    return jsonify(get_public_profile_details(profile, False,
                                              textures_host)), 200
Exemplo n.º 2
0
def json_and_response_code(request):
    if len(request.json) > 10:
        return OVER_PROFILE_LIMIT.dual

    uuids = []

    for name in request.json:
        profile = Profile.get_profile_with_name(name)
        if profile is None:
            continue

        uuids.append({"id": profile.uuid.hex, "name": profile.name})

    return jsonify(uuids), 200