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")
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")
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 ) )
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")
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" )
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" )
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")
def login(): username = quorum.get_field("username", "anonymous") flask.session["active"] = True flask.session["username"] = username return flask.redirect( flask.url_for("index") )
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" )
def create(): name = quorum.get_field("name", "example") proxy = pushi.API() proxy.create_app( name = name ) return flask.render_template( "success.html.tpl" )
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" )
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))
def create(): name = quorum.get_field("name", "example") proxy = pushi.API() proxy.create_app(name=name) return flask.render_template("success.html.tpl")
def login(): username = quorum.get_field("username", "anonymous") flask.session["active"] = True flask.session["username"] = username return flask.redirect(flask.url_for("index"))