def send_notifications(post, args): if not post.hidden and not post.draft: urls = [ url_for('views.index', _external=True), url_for('views.index', feed='atom', _external=True), ] get_queue().enqueue(publish, urls, current_app.config)
def send_notifications(post, args): if not post.hidden and not post.draft and 'PUSH_HUB' in current_app.config: urls = [ url_for('views.index', _external=True), url_for('views.index', feed='atom', _external=True), ] get_queue().enqueue(publish, urls, current_app.config['PUSH_HUB'])
def send_webmentions_on_comment(post): try: current_app.logger.debug("queueing webmentions for {}".format(post.id)) get_queue().enqueue(do_send_webmentions, post.id, current_app.config) return True, 'Success' except Exception as e: current_app.logger.exception('sending webmentions') return False, "Exception while sending webmention: {}"\ .format(e)
def send_webmentions_on_delete(post, args): try: current_app.logger.debug("queueing deletion webmentions for %s", post.id) get_queue().enqueue(do_send_webmentions, post.id, current_app.config['CONFIG_FILE']) return True, 'Success' except Exception as e: current_app.logger.exception('sending deletion webmentions') return False, "Exception while sending deletion webmention: {}"\ .format(e)
def send_webmentions_on_comment(post): try: if post: current_app.logger.debug("queueing webmentions for {}".format(post.id)) get_queue().enqueue(do_send_webmentions, post.id, current_app.config['CONFIG_FILE']) return True, 'Success' except Exception as e: current_app.logger.exception('sending webmentions') return False, "Exception while sending webmention: {}"\ .format(e)
def send_to_facebook(post, args): if "facebook" in args.getlist("syndicate-to"): if not is_facebook_authorized(): return False, "Current user is not authorized to post to Facebook" try: current_app.logger.debug("auto-posting to Facebook %s", post.id) get_queue().enqueue(do_send_to_facebook, post.id, current_app.config["CONFIG_FILE"]) return True, "Success" except Exception as e: current_app.logger.exception("auto-posting to facebook") return False, "Exception while auto-posting to FB: {}".format(e)
def send_to_facebook(post, args): if 'facebook' in args.getlist('syndicate-to'): if not is_facebook_authorized(): return False, 'Current user is not authorized to post to Facebook' try: current_app.logger.debug('auto-posting to Facebook %s', post.id) get_queue().enqueue( do_send_to_facebook, post.id, current_app.config) return True, 'Success' except Exception as e: current_app.logger.exception('auto-posting to facebook') return False, 'Exception while auto-posting to FB: {}'.format(e)
def send_to_facebook(post, args): if 'facebook' in args.getlist('syndicate-to'): if not is_facebook_authorized(): return False, 'Current user is not authorized to post to Facebook' try: current_app.logger.debug('auto-posting to Facebook %s', post.id) get_queue().enqueue( do_send_to_facebook, post.id, current_app.config['CONFIG_FILE']) return True, 'Success' except Exception as e: current_app.logger.exception('auto-posting to facebook') return False, 'Exception while auto-posting to FB: {}'.format(e)
def send_webmentions_on_save(post, args): if args.get('action') in ('save_draft', 'publish_quietly'): current_app.logger.debug('skipping webmentions for {}'.format(post.id)) return try: current_app.logger.debug("queueing webmentions for {}".format(post.id)) get_queue().enqueue(do_send_webmentions, post.id, current_app.config['CONFIG_FILE']) return True, 'Success' except Exception as e: current_app.logger.exception('sending webmentions') return False, "Exception while sending webmention: {}"\ .format(e)
def receive_webmention(): if request.method == 'GET': return render_template('webmention.jinja2') source = request.form.get('source') target = request.form.get('target') callback = request.form.get('callback') if not source: return make_response( 'webmention missing required source parameter', 400) if not target: return make_response( 'webmention missing required target parameter', 400) current_app.logger.debug( "Webmention from %s to %s received", source, target) job = get_queue().enqueue( do_process_webmention, source, target, callback, current_app.config['CONFIG_FILE']) status_url = url_for('.webmention_status', key=job.id, _external=True) return make_response( render_template('wm_received.jinja2', status_url=status_url), 202)
def receive_webmention(): if request.method == 'GET': return render_template('webmention.jinja2') source = request.form.get('source') target = request.form.get('target') callback = request.form.get('callback') if not source: return make_response('webmention missing required source parameter', 400) if not target: return make_response('webmention missing required target parameter', 400) current_app.logger.debug("Webmention from %s to %s received", source, target) job = get_queue().enqueue(do_process_webmention, source, target, callback, current_app.config['CONFIG_FILE']) status_url = url_for('.webmention_status', key=job.id, _external=True) return make_response( render_template('wm_received.jinja2', status_url=status_url), 202)
def send_to_twitter(post, args): """Share a note to twitter without user-input. Makes a best-effort attempt to guess the appropriate parameters and content """ if 'twitter' in args.getlist('syndicate-to'): if not is_twitter_authorized(): return False, 'Current user is not authorized to tweets' try: current_app.logger.debug('auto-posting to twitter %r', post.id) get_queue().enqueue( do_send_to_twitter, post.id, current_app.config['CONFIG_FILE']) return True, 'Success' except Exception as e: current_app.logger.exception('auto-posting to twitter') return (False, 'Exception while auto-posting to twitter: {}' .format(e))
def send_to_twitter(post, args): """Share a note to twitter without user-input. Makes a best-effort attempt to guess the appropriate parameters and content """ if 'twitter' in args.getlist('syndicate-to'): if not is_twitter_authorized(): return False, 'Current user is not authorized to tweets' try: current_app.logger.debug('auto-posting to twitter %r', post.id) get_queue().enqueue(do_send_to_twitter, post.id, current_app.config['CONFIG_FILE']) return True, 'Success' except Exception as e: current_app.logger.exception('auto-posting to twitter') return (False, 'Exception while auto-posting to twitter: {}'.format(e))
def webmention_status(key): job = get_queue().fetch_job(key) if not job: rv = {"response_code": 400, "status": "unknown", "reason": "Job does not exist or its status has expired"} elif job.result == "queued": rv = {"response_code": 202, "status": "queued", "reason": "Mention has been queued for processing"} else: rv = job.result or {} return make_response(render_template("wm_status.jinja2", **rv), rv.get("response_code", 400))
def receive_webmention(): if request.method == "GET": return render_template("webmention.jinja2") source = request.form.get("source") target = request.form.get("target") callback = request.form.get("callback") if not source: return make_response("webmention missing required source parameter", 400) if not target: return make_response("webmention missing required target parameter", 400) current_app.logger.debug("Webmention from %s to %s received", source, target) job = get_queue().enqueue(do_process_webmention, source, target, callback, current_app.config) status_url = url_for(".webmention_status", key=job.id, _external=True) return make_response(render_template("wm_received.jinja2", status_url=status_url), 202)
def webmention_status(key): job = get_queue().fetch_job(key) if not job: rv = { 'response_code': 400, 'status': 'unknown', 'reason': 'Job does not exist or its status has expired', } elif job.result == 'queued': rv = { 'response_code': 202, 'status': 'queued', 'reason': 'Mention has been queued for processing', } else: rv = job.result or {} return make_response(render_template('wm_status.jinja2', **rv), rv.get('response_code', 400))
def webmention_status(key): job = get_queue().fetch_job(key) if not job: rv = { 'response_code': 400, 'status': 'unknown', 'reason': 'Job does not exist or its status has expired', } elif job.result == 'queued': rv = { 'response_code': 202, 'status': 'queued', 'reason': 'Mention has been queued for processing', } else: rv = job.result or {} return make_response( render_template('wm_status.jinja2', **rv), rv.get('response_code', 400))
def reverse_geocode_venue(venue, args): get_queue().enqueue(do_reverse_geocode_venue, venue.id, current_app.config)
def reverse_geocode(post, args): get_queue().enqueue(do_reverse_geocode_post, post.id, current_app.config)
def reverse_geocode(post, args): get_queue().enqueue(do_reverse_geocode_post, post.id, current_app.config['CONFIG_FILE'])
def send_to_wordpress(post, args): if 'wordpress' in args.getlist('syndicate-to'): get_queue().enqueue(do_send_to_wordpress, post.id, current_app.config['CONFIG_FILE'])
def syndicate(post, args): syndto = args.getlist('syndicate-to') for target in PosseTarget.query.filter(PosseTarget.uid.in_(syndto)): current_app.logger.debug('enqueuing task to posse to %s', target.uid) get_queue().enqueue(do_syndicate, post.id, target.id, current_app.config['CONFIG_FILE'])
def send_notifications(post, args): if not post.hidden and not post.draft and "PUSH_HUB" in current_app.config: urls = [url_for("views.index", _external=True), url_for("views.index", feed="atom", _external=True)] get_queue().enqueue(publish, urls, current_app.config["PUSH_HUB"])
def reverse_geocode_venue(venue, args): get_queue().enqueue(do_reverse_geocode_venue, venue.id, current_app.config['CONFIG_FILE'])