def post(self): """Perform an action.""" form = web.form("action", channel="default") response = {} if form.action == "channels": web.tx.sub.add_channel(form.name) response = {"channels": web.tx.sub.get_channels()} elif form.action == "search": response = {"results": web.tx.sub.search(form.query)} elif form.action == "preview": response = web.tx.sub.preview(form.url) elif form.action == "follow": web.tx.sub.follow(form.url) response = {"items": web.tx.sub.get_following()} web.enqueue(websub.subscribe, f"{web.tx.origin}/subscriptions/sent", form.url) elif form.action == "unfollow": pass elif form.action == "timeline": pass elif form.action == "mute": pass elif form.action == "unmute": pass elif form.action == "block": pass elif form.action == "unblock": pass web.header("Content-Type", "application/json") return response
def post(self): program = web.form("program").program machine = tx.db.select("machines", where="name = ?", vals=[self.machine])[0] web.enqueue(build, machine["ip_address"], program) raise web.Accepted(f"{program} is building on the machine..")
def post(self): name = web.form("name").name token = tx.db.select("providers", where="service = ?", vals=["digitalocean.com"])[0]["token"] web.enqueue(spawn_machine, name, token) raise web.Accepted("machine is being created..")
def post(self): try: topic_url = web.form("topic_url").topic_url except web.BadRequest: pass else: web.enqueue(websub.subscribe, f"{web.tx.origin}/subscriptions/sent", topic_url) return app.view.sent.subscription_requested() mode = web.form("hub.mode")["hub.mode"] if mode != "subscribe": raise web.BadRequest( 'hub only supports subscription; `hub.mode` must be "subscribe"' ) form = web.form("hub.topic", "hub.callback") # TODO raise web.BadRequest("topic not found") web.enqueue(websub.verify_received_subscription, form["hub.topic"], form["hub.callback"]) raise web.Accepted("subscription request accepted")
def get(self): """Confirm subscription request.""" try: action = web.form("action").action except web.BadRequest: pass else: if action == "unsubscribe": web.enqueue(websub.unsubscribe, self.subscription_id) return "unsubscribed" raise web.BadRequest("action must be `unsubscribe`") try: form = web.form("hub.mode", "hub.topic", "hub.challenge", "hub.lease_seconds") except web.BadRequest: pass else: web.tx.websub.verify_sent_subscription( form["hub.topic"], f"{web.tx.origin}/subscriptions/sent/{self.subscription_id}", ) # TODO verify the subscription return form["hub.challenge"] return "sent sub"
def post(self): web.enqueue(update_system) raise web.Accepted(app.view.update())
def post(self): """""" form = web.form("source", "target") web.enqueue(receive, form.source, form.target) raise web.Accepted("webmention received")
def post(self): web.enqueue(spawn_canopy, web.tx.providers.get_digitalocean_token()) raise web.Accepted("canopy tree is being spawned in the cloud..")
def post(self): machine = tx.db.select("machines", where="name = ?", vals=[self.machine])[0] web.enqueue(host.upgrade_system, machine["ip_address"]) raise web.Accepted("system is updating on the machine..")