From 1e38fcf9b34c1bba44dd941a099ddd9fa76817e9 Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Wed, 3 Apr 2024 16:35:26 +1300 Subject: [PATCH] api/v1/instance endpoint, for fedidb --- app/activitypub/routes.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/activitypub/routes.py b/app/activitypub/routes.py index fe5950ae..987042bb 100644 --- a/app/activitypub/routes.py +++ b/app/activitypub/routes.py @@ -117,6 +117,23 @@ def nodeinfo2(): return jsonify(nodeinfo_data) +@bp.route('/api/v1/instance') +@cache.cached(timeout=600) +def api_v1_instance(): + retval = { + 'title': g.site.name, + 'uri': current_app.config['SERVER_NAME'], + 'stats': { + "user_count": users_total(), + "status_count": local_posts() + local_comments(), + "domain_count": 1 + }, + 'registrations': g.site.registration_mode != 'Closed', + 'approval_required': g.site.registration_mode == 'RequireApplication' + } + return jsonify(retval) + + @bp.route('/api/v1/instance/domain_blocks') @cache.cached(timeout=600) def domain_blocks():