Example #1
0
def update_location():
    try:
        user_id = int(flask.request.args.get('user_id'))
        channel_id = int(flask.request.args.get('channel_id'))
        longitude = flask.request.args.get('longitude')
        latitude = flask.request.args.get('latitude')
        core = amberalertcn.Application.current_core()
        resp = core.update_location(user_id, channel_id, longitude, latitude)
        return utils.make_json_response(resp)
    except Exception as e:
        print("!!! ", e)
        return utils.make_json_response(None)
Example #2
0
def get_all_alerts():
    try:
        core = amberalertcn.Application.current_core()
        resp = core.get_all_alerts()
        return utils.make_json_alerts_response(resp)
    except Exception as e:
        print(e)
        return utils.make_json_response(None)
Example #3
0
def send_message():
    try:
        user_id = int(flask.request.args.get('user_id'))
        channel_id = int(flask.request.args.get('channel_id'))
        receiver = int(flask.request.args.get('amber_alert_id'))
        user_name = flask.request.args.get('user_name')
        user_face = flask.request.args.get('user_face')
        location = flask.request.args.get('location')
        message_json_str = flask.request.data.encode('utf-8')
        message_json = json.loads(message_json_str)
        message = message_json["message"]
        core = amberalertcn.Application.current_core()
        resp = core.send_message(user_id, channel_id, receiver, user_name, user_face, location, message)
        return utils.make_json_response(resp)
    except Exception as e:
        print(e)
        return utils.make_json_response(None)
Example #4
0
def get_my_following_alerts():
    try:
        core = amberalertcn.Application.current_core()
        user_id = int(flask.request.args.get('user_id'))
        resp = core.get_my_following_alerts(user_id)
        return utils.make_json_alerts_response(resp)
    except Exception as e:
        print(e)
        return utils.make_json_response(None)
Example #5
0
def publish_alert():
    try:
        user_id = int(flask.request.args.get('user_id'))
        channel_id = int(flask.request.args.get('channel_id'))
        user_name = flask.request.args.get('user_name')
        user_face = flask.request.args.get('user_face')
        location = flask.request.args.get('location')
        longitude = float(flask.request.args.get('longitude'))
        latitude = float(flask.request.args.get('latitude'))
        message_json_str = flask.request.data.encode('utf-8')
        message_json = json.loads(message_json_str)
        message = message_json["message"]
        child_id = 0 # no use
        core = amberalertcn.Application.current_core()
        resp = core.publish_alert(user_id, channel_id, child_id, \
                user_name, user_face, location, longitude, latitude, message)
        return utils.make_json_response(resp)
    except Exception as e:
        print(e)
        return utils.make_json_response(None)