Exemplo n.º 1
0
def sync(request_json):
    app = db.get_app_from_key(request_json['_app_key'])
    if not app:
        data = {'app_key': request_json['_app_key']}
        return utils.jsonrpc_error(request_json, 8, data)

    app_version = db.get_app_version_for_bundle_version(app['id'],
        request_json['_bundle_version'])

    # If the app is over the limit and they're not a first-time customer, then
    # we return an error instead of the updated file list.
    if request_json['_app_version'] != '-1' and not app['enabled']:
        return utils.jsonrpc_error(request_json, 15, {})

    device = db.get_device_for_udid_and_app(request_json['_udid'], app['id'])

    return utils.jsonrpc_response(request_json, {
        'files': _get_file_list(app, app_version),
        'conf': _get_conf(app, app_version, device),
    })
Exemplo n.º 2
0
def sync(request_json):
    app = db.get_app_from_key(request_json['_app_key'])
    if not app:
        data = {'app_key': request_json['_app_key']}
        return utils.jsonrpc_error(request_json, 8, data)

    app_version = db.get_app_version_for_bundle_version(
        app['id'], request_json['_bundle_version'])

    # If the app is over the limit and they're not a first-time customer, then
    # we return an error instead of the updated file list.
    if request_json['_app_version'] != '-1' and not app['enabled']:
        return utils.jsonrpc_error(request_json, 15, {})

    device = db.get_device_for_udid_and_app(request_json['_udid'], app['id'])

    return utils.jsonrpc_response(
        request_json, {
            'files': _get_file_list(app, app_version),
            'conf': _get_conf(app, app_version, device),
        })
Exemplo n.º 3
0
def device_authenticate(request_json, device_id=None, app_key=None):
    app = db.get_app_from_key(app_key)

    if app:
        device = db.get_device_for_udid_and_app(device_id, app['id'])
    else:
        device = None

    data = {}
    if device:
        data['user'] = {
            'user_id': device['user_id'],
            'username': device['username'],
            'email': device['email'],
        }
    if app:
        data['app'] = {
            'app_id': app['id'],
            'slug': app['slug'],
            'name': app['name'],
        }
    return utils.jsonrpc_response(request_json, data)
Exemplo n.º 4
0
def device_authenticate(request_json, device_id=None, app_key=None):
    app = db.get_app_from_key(app_key)

    if app:
        device = db.get_device_for_udid_and_app(device_id, app['id'])
    else:
        device = None

    data = {}
    if device:
        data['user'] = {
            'user_id': device['user_id'],
            'username': device['username'],
            'email': device['email'],
        }
    if app:
        data['app'] = {
            'app_id': app['id'],
            'slug': app['slug'],
            'name': app['name'],
        }
    return utils.jsonrpc_response(request_json, data)