Tweak AP ctx, and gzip support for HTML resp
This commit is contained in:
@@ -263,6 +263,9 @@ def post_to_outbox(activity: ap.BaseActivity) -> str:
|
||||
class MicroblogPubBackend(Backend):
|
||||
"""Implements a Little Boxes backend, backed by MongoDB."""
|
||||
|
||||
def ap_context(self) -> Any:
|
||||
return DEFAULT_CTX
|
||||
|
||||
def base_url(self) -> str:
|
||||
return BASE_URL
|
||||
|
||||
|
@@ -59,7 +59,19 @@ def build_resp(resp):
|
||||
return resp, headers
|
||||
|
||||
|
||||
def jsonify(**data):
|
||||
def htmlify(data):
|
||||
resp, headers = build_resp(data)
|
||||
return Response(
|
||||
response=resp,
|
||||
headers={
|
||||
**headers,
|
||||
"Content-Type": "text/html; charset=utf-8",
|
||||
"Cache-Control": "max-age=0, private, must-revalidate",
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def activitypubify(**data):
|
||||
if "@context" not in data:
|
||||
data["@context"] = config.DEFAULT_CTX
|
||||
resp, headers = build_resp(json.dumps(data))
|
||||
@@ -68,9 +80,7 @@ def jsonify(**data):
|
||||
headers={
|
||||
**headers,
|
||||
"Cache-Control": "max-age=0, private, must-revalidate",
|
||||
"Content-Type": "application/json"
|
||||
if app.debug
|
||||
else "application/activity+json",
|
||||
"Content-Type": "application/activity+json",
|
||||
},
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user