From 49eb9b8541c68c2ce20531254d7c8ff91243635f Mon Sep 17 00:00:00 2001 From: Ryan Barrett Date: Sun, 31 Dec 2023 08:42:26 -0800 Subject: [PATCH] add Mastodon instance info at /api/v1/instance https://docs.joinmastodon.org/methods/instance/#v1 right now just for FediSeer: https://fediseer.com/faq/eng#how-can-i-claim-my-instance --- pages.py | 27 +++++++++++++++++++++++++++ tests/test_pages.py | 4 ++++ 2 files changed, 31 insertions(+) diff --git a/pages.py b/pages.py index 8fe96ba..e51065d 100644 --- a/pages.py +++ b/pages.py @@ -372,6 +372,33 @@ def nodeinfo(): } +@app.get('/api/v1/instance') +@canonicalize_request_domain(common.PROTOCOL_DOMAINS, common.PRIMARY_DOMAIN) +@flask_util.cached(cache, datetime.timedelta(days=1)) +def instance_info(): + """ + https://docs.joinmastodon.org/methods/instance/#v1 + """ + return { + 'uri': 'fed.brid.gy', + 'title': 'Bridgy Fed', + 'version': os.getenv('GAE_VERSION'), + 'short_description': 'Bridging the new social internet', + 'description': 'Bridging the new social internet', + 'email': 'feedback@ryanb.org', + 'thumbnail': 'https://fed.brid.gy/static/bridgy_logo_with_alpha.png', + 'registrations': True, + 'approval_required': False, + 'invites_enabled': False, + 'contact_account': { + 'username': 'snarfed.org', + 'acct': 'snarfed.org', + 'display_name': 'Ryan', + 'url': 'https://snarfed.org/', + }, + } + + @app.get('/log') @canonicalize_request_domain(common.PROTOCOL_DOMAINS, common.PRIMARY_DOMAIN) @flask_util.cached(cache, logs.CACHE_TIME) diff --git a/tests/test_pages.py b/tests/test_pages.py index 03660c9..baa0751 100644 --- a/tests/test_pages.py +++ b/tests/test_pages.py @@ -445,6 +445,10 @@ class PagesTest(TestCase): # just check that it doesn't crash self.client.get('/nodeinfo.json') + def test_instance_info(self): + # just check that it doesn't crash + self.client.get('/api/v1/instance') + def test_canonicalize_domain(self): got = self.client.get('/', base_url='https://ap.brid.gy/') self.assert_equals(301, got.status_code)