From ef5b32a33cdf8ef7b9bea91fe43d5522272835f0 Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Sun, 3 Jun 2018 10:15:11 +0200 Subject: [PATCH] Add NodeInfo support --- app.py | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 0fd10db..de08979 100644 --- a/app.py +++ b/app.py @@ -447,8 +447,39 @@ def note_by_id(note_id): return render_template('note.html', me=ME, note=data, replies=replies) +@app.route('/nodeinfo') +def nodeinfo(): + return Response( + headers={'Content-Type': 'application/json; profile=http://nodeinfo.diaspora.software/ns/schema/2.0#'}, + response=json.dumps({ + 'version': '2.0', + 'software': {'name': 'microblogpub', 'version': f'Microblog.pub {VERSION}'}, + 'protocols': ['activitypub'], + 'services': {'inbound': [], 'outbound': []}, + 'openRegistrations': False, + 'usage': {'users': {'total': 1}, 'localPosts': DB.outbox.count()}, + 'metadata': { + 'sourceCode': 'https://github.com/tsileo/microblog.pub', + }, + }), + ) + + +@app.route('/.well-known/nodeinfo') +def wellknown_nodeinfo(): + return flask_jsonify( + links=[ + { + 'rel': 'http://nodeinfo.diaspora.software/ns/schema/2.0', + 'href': f'{ID}/nodeinfo', + } + + ], + ) + + @app.route('/.well-known/webfinger') -def webfinger(): +def wellknown_webfinger(): """Enable WebFinger support, required for Mastodon interopability.""" resource = request.args.get('resource') if resource not in ["acct:"+USERNAME+"@"+DOMAIN, ID]: