diff --git a/activitypub.py b/activitypub.py index 49eaa13..1e7350b 100644 --- a/activitypub.py +++ b/activitypub.py @@ -10,7 +10,7 @@ from flask import request from google.cloud import ndb from granary import as2, microformats2 import mf2util -from oauth_dropins.webutil import util +from oauth_dropins.webutil import flask_util, util from oauth_dropins.webutil.flask_util import error from oauth_dropins.webutil.util import json_dumps, json_loads @@ -79,7 +79,7 @@ def send(activity, inbox_url, user_domain): @app.get(f'/') -@cache.cached(CACHE_TIME.total_seconds()) +@flask_util.cached(cache, CACHE_TIME) def actor(domain): """Serves /[DOMAIN], fetches its mf2, converts to AS Actor, and serves it.""" tld = domain.split('.')[-1] diff --git a/add_webmention.py b/add_webmention.py index 047b3a2..1e7f208 100644 --- a/add_webmention.py +++ b/add_webmention.py @@ -17,8 +17,7 @@ CACHE_TIME = datetime.timedelta(seconds=15) @app.get(r'/wm/') -@cache.cached(timeout=CACHE_TIME.total_seconds(), query_string=True, - response_filter=flask_util.not_5xx) +@flask_util.cached(cache, CACHE_TIME) def add_wm(url=None): """Proxies HTTP requests and adds Link header to our webmention endpoint.""" url = urllib.parse.unquote(url) diff --git a/redirect.py b/redirect.py index 62393eb..3476858 100644 --- a/redirect.py +++ b/redirect.py @@ -29,8 +29,7 @@ CACHE_TIME = datetime.timedelta(seconds=15) @app.get(r'/r/') -@cache.cached(timeout=CACHE_TIME.total_seconds(), query_string=True, - response_filter=flask_util.not_5xx) +@flask_util.cached(cache, CACHE_TIME) def redir(to): """301 redirect to the embedded fully qualified URL. diff --git a/render.py b/render.py index c7b45c6..a5c7a38 100644 --- a/render.py +++ b/render.py @@ -16,8 +16,7 @@ CACHE_TIME = datetime.timedelta(minutes=15) @app.get('/render') -@cache.cached(timeout=CACHE_TIME.total_seconds(), query_string=True, - response_filter=flask_util.not_5xx) +@flask_util.cached(cache, CACHE_TIME) def render(): """Fetches a stored Response and renders it as HTML.""" source = flask_util.get_required_param('source')