Beispiel #1
0
def unsubscribe_apn():
    token = quorum.get_field("token")
    event = quorum.get_field("event", "global")

    proxy = pushi.API()
    proxy.unsubscribe_apn(token=token, event=event)
    return flask.render_template("success.html.tpl")
Beispiel #2
0
def notification():
    channel = quorum.get_field("channel", "global")
    message = quorum.get_field("message", "hello world")

    proxy = pushi.API()
    proxy.trigger_event(channel=channel, data=message, event="message")
    return flask.render_template("success.html.tpl")
Beispiel #3
0
def auth():
    # check if the the session is currently active (user logged in)
    # in case it's not raises an error for the problem
    is_active = flask.session.get("active", False)
    if not is_active: raise RuntimeError("User is not authenticated")

    # retrieves the current username in session, defaulting to
    # anonymous in case no username is currently in session
    username = flask.session.get("username", "anonymous")

    # retrieves both the channel and the socket id information
    # from the provided field parameters, these values are going
    # to be used in the authentication process
    channel = quorum.get_field("channel")
    socket_id = quorum.get_field("socket_id")

    # authenticates the provided socket id in the provided channel
    # retrieving the token for authentication and returning a message
    # containing both the authentication token and the user info
    auth = pushi.API().authenticate(channel, socket_id)
    return dict(
        auth = auth,
        channel_data = dict(
            user_id = username,
            username = username,
            peer = True
        )
    )
Beispiel #4
0
def subscribe_apn():
    token = quorum.get_field("token")
    event = quorum.get_field("event", "global")

    if not token: raise RuntimeError("no APN device token provided")

    proxy = pushi.API()
    auth = proxy.authenticate(event, token)
    proxy.subscribe_apn(token=token, event=event, auth=auth)
    return flask.render_template("success.html.tpl")
Beispiel #5
0
def unsubscribe_apn():
    token = quorum.get_field("token")
    event = quorum.get_field("event", "global")

    proxy = pushi.API()
    proxy.unsubscribe_apn(
        token = token,
        event = event
    )
    return flask.render_template(
        "success.html.tpl"
    )
Beispiel #6
0
def notification():
    channel = quorum.get_field("channel", "global")
    message = quorum.get_field("message", "hello world")

    proxy = pushi.API()
    proxy.trigger_event(
        channel = channel,
        data = message,
        event = "message"
    )
    return flask.render_template(
        "success.html.tpl"
    )
Beispiel #7
0
def subscribe():
    event = quorum.get_field("event", "global")
    user_id = flask.session.get("username", "anonymous")

    proxy = pushi.API()
    proxy.subscribe(user_id=user_id, event=event)
    return flask.render_template("success.html.tpl")
Beispiel #8
0
def login():
    username = quorum.get_field("username", "anonymous")
    flask.session["active"] = True
    flask.session["username"] = username
    return flask.redirect(
        flask.url_for("index")
    )
Beispiel #9
0
def subscribe_apn():
    token = quorum.get_field("token")
    event = quorum.get_field("event", "global")

    if not token: raise RuntimeError("no apn device token provided")

    proxy = pushi.API()
    auth = proxy.authenticate(event, token)
    proxy.subscribe_apn(
        token = token,
        event = event,
        auth = auth
    )
    return flask.render_template(
        "success.html.tpl"
    )
Beispiel #10
0
def create():
    name = quorum.get_field("name", "example")

    proxy = pushi.API()
    proxy.create_app(
        name = name
    )
    return flask.render_template(
        "success.html.tpl"
    )
Beispiel #11
0
def unsubscribe():
    event = quorum.get_field("event", "global")
    user_id = flask.session.get("username", "anonymous")

    proxy = pushi.API()
    proxy.unsubscribe(
        user_id = user_id,
        event = event
    )
    return flask.render_template(
        "success.html.tpl"
    )
Beispiel #12
0
def auth():
    # check if the the session is currently active (user logged in)
    # in case it's not raises an error for the problem
    is_active = flask.session.get("active", False)
    if not is_active: raise RuntimeError("User is not authenticated")

    # retrieves the current username in session, defaulting to
    # anonymous in case no username is currently in session
    username = flask.session.get("username", "anonymous")

    # retrieves both the channel and the socket id information
    # from the provided field parameters, these values are going
    # to be used in the authentication process
    channel = quorum.get_field("channel")
    socket_id = quorum.get_field("socket_id")

    # authenticates the provided socket id in the provided channel
    # retrieving the token for authentication and returning a message
    # containing both the authentication token and the user info
    auth = pushi.API().authenticate(channel, socket_id)
    return dict(auth=auth,
                channel_data=dict(user_id=username,
                                  username=username,
                                  peer=True))
Beispiel #13
0
def create():
    name = quorum.get_field("name", "example")

    proxy = pushi.API()
    proxy.create_app(name=name)
    return flask.render_template("success.html.tpl")
Beispiel #14
0
def login():
    username = quorum.get_field("username", "anonymous")
    flask.session["active"] = True
    flask.session["username"] = username
    return flask.redirect(flask.url_for("index"))