Use the toot namespace/AP extension

This commit is contained in:
Thomas Sileo 2018-07-22 21:34:42 +02:00
parent fcf9524ac0
commit e2d814a456
2 changed files with 10 additions and 15 deletions

18
app.py
View file

@ -276,9 +276,9 @@ def domain(url):
@app.template_filter()
def url_or_id(d):
if 'url' in d:
return d['url']
return d['id']
if "url" in d:
return d["url"]
return d["id"]
@app.template_filter()
@ -355,6 +355,7 @@ def is_img(filename):
def add_response_headers(headers={}):
"""This decorator adds the headers passed in to the response"""
def decorator(f):
@wraps(f)
def decorated_function(*args, **kwargs):
@ -363,13 +364,15 @@ def add_response_headers(headers={}):
for header, value in headers.items():
h[header] = value
return resp
return decorated_function
return decorator
def noindex(f):
"""This decorator passes X-Robots-Tag: noindex, nofollow"""
return add_response_headers({'X-Robots-Tag': 'noindex, nofollow'})(f)
return add_response_headers({"X-Robots-Tag": "noindex, nofollow"})(f)
def login_required(f):
@ -415,7 +418,7 @@ def api_required(f):
def jsonify(**data):
if "@context" not in data:
data["@context"] = config.CTX_AS
data["@context"] = config.DEFAULT_CTX
return Response(
response=json.dumps(data),
headers={
@ -978,11 +981,6 @@ def wellknown_nodeinfo():
)
# @app.route('/fake_feed')
# def fake_feed():
# return '<?xml version="1.0"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:activity="http://activitystrea.ms/spec/1.0/" xmlns:poco="http://portablecontacts.net/spec/1.0" xmlns:ostatus="http://ostatus.org/schema/1.0"><id>https://lol3.tun.a4.io/fake_feed</id><author><id>https://lol3.tun.a4.io/fake</id></author><entry></entry></feed>'
@app.route("/.well-known/webfinger")
def wellknown_webfinger():
"""Enable WebFinger support, required for Mastodon interopability."""

View file

@ -9,6 +9,7 @@ import sass
import yaml
from itsdangerous import JSONWebSignatureSerializer
from little_boxes import strtobool
from little_boxes.activitypub import DEFAULT_CTX
from pymongo import MongoClient
from utils.key import KEY_DIR
@ -46,10 +47,6 @@ VERSION = (
DEBUG_MODE = strtobool(os.getenv("MICROBLOGPUB_DEBUG", "false"))
CTX_AS = "https://www.w3.org/ns/activitystreams"
CTX_SECURITY = "https://w3id.org/security/v1"
AS_PUBLIC = "https://www.w3.org/ns/activitystreams#Public"
HEADERS = [
"application/activity+json",
"application/ld+json;profile=https://www.w3.org/ns/activitystreams",
@ -129,7 +126,7 @@ def _admin_jwt_token() -> str:
ADMIN_API_KEY = get_secret_key("admin_api_key", _admin_jwt_token)
ME = {
"@context": [CTX_AS, CTX_SECURITY],
"@context": DEFAULT_CTX,
"type": "Person",
"id": ID,
"following": ID + "/following",