|
2 | 2 | import calendar |
3 | 3 | import datetime |
4 | 4 | import logging |
| 5 | +import os |
5 | 6 | import re |
6 | 7 | import urllib.parse |
7 | 8 |
|
@@ -247,6 +248,66 @@ def count(kind): |
247 | 248 | ) |
248 | 249 |
|
249 | 250 |
|
| 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 | + |
250 | 311 | @app.get('/log') |
251 | 312 | @flask_util.cached(cache, logs.CACHE_TIME) |
252 | 313 | def log(): |
|
0 commit comments