2018-08-10 20:15:02 +00:00
|
|
|
import aiohttp.web
|
|
|
|
from . import app
|
|
|
|
|
|
|
|
|
|
|
|
async def webfinger(request):
|
|
|
|
subject = request.query['resource']
|
|
|
|
|
2018-10-30 01:42:17 +00:00
|
|
|
if subject != 'acct:relay@{}'.format(request.host):
|
2018-08-10 20:15:02 +00:00
|
|
|
return aiohttp.web.json_response({'error': 'user not found'}, status=404)
|
|
|
|
|
|
|
|
actor_uri = "https://{}/actor".format(request.host)
|
|
|
|
data = {
|
|
|
|
"aliases": [actor_uri],
|
|
|
|
"links": [
|
|
|
|
{"href": actor_uri, "rel": "self", "type": "application/activity+json"},
|
|
|
|
{"href": actor_uri, "rel": "self", "type": "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""}
|
|
|
|
],
|
|
|
|
"subject": subject
|
|
|
|
}
|
|
|
|
|
|
|
|
return aiohttp.web.json_response(data)
|
|
|
|
|
|
|
|
|
|
|
|
app.router.add_get('/.well-known/webfinger', webfinger)
|