Skip to content

Commit c68e066

Browse files
committed
1 parent b5a0386 commit c68e066

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

pages.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import calendar
33
import datetime
44
import logging
5+
import os
56
import re
67
import urllib.parse
78

@@ -247,6 +248,66 @@ def count(kind):
247248
)
248249

249250

251+
@app.get('/.well-known/nodeinfo')
252+
@flask_util.cached(cache, datetime.timedelta(days=1))
253+
def nodeinfo_jrd():
254+
"""
255+
https://nodeinfo.diaspora.software/protocol.html
256+
"""
257+
return {
258+
'links': [{
259+
'rel': 'http://nodeinfo.diaspora.software/ns/schema/2.1',
260+
'href': common.host_url('nodeinfo.json'),
261+
}],
262+
}, {
263+
'Content-Type': 'application/jrd+json',
264+
}
265+
266+
267+
@app.get('/nodeinfo.json')
268+
@flask_util.cached(cache, datetime.timedelta(days=1))
269+
def nodeinfo():
270+
"""
271+
https://nodeinfo.diaspora.software/schema.html
272+
"""
273+
return {
274+
'version': '2.1',
275+
'software': {
276+
'name': 'bridgy-fed',
277+
'version': os.getenv('GAE_VERSION'),
278+
'repository': 'https://github.com/snarfed/bridgy-fed',
279+
'homepage': 'https://fed.brid.gy/',
280+
},
281+
'protocols': [
282+
'activitypub',
283+
'bluesky',
284+
'webmention',
285+
],
286+
'services': {
287+
'outbound': [],
288+
'inbound': [],
289+
},
290+
'usage': {
291+
'users': {
292+
'total': KindStat.query(KindStat.kind_name == 'MagicKey').get().count,
293+
# 'activeMonth':
294+
# 'activeHalfyear':
295+
},
296+
'localPosts': Object.query(Object.source_protocol == 'webmention',
297+
Object.type.IN(['note', 'article']),
298+
).count(),
299+
'localComments': Object.query(Object.source_protocol == 'webmention',
300+
Object.type == 'comment',
301+
).count(),
302+
},
303+
'openRegistrations': True,
304+
'metadata': {},
305+
}, {
306+
# https://nodeinfo.diaspora.software/protocol.html
307+
'Content-Type': 'application/json; profile="http://nodeinfo.diaspora.software/ns/schema/2.1#"',
308+
}
309+
310+
250311
@app.get('/log')
251312
@flask_util.cached(cache, logs.CACHE_TIME)
252313
def log():

0 commit comments

Comments
 (0)