From d85ffaec04f14789378eedb3a43697b4e836e142 Mon Sep 17 00:00:00 2001 From: Ryan Barrett Date: Wed, 25 Jan 2023 13:12:24 -0800 Subject: [PATCH] implement stub empty outbox for #383 --- activitypub.py | 17 +++++++++++++++++ tests/test_activitypub.py | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/activitypub.py b/activitypub.py index f832d51..fac4200 100644 --- a/activitypub.py +++ b/activitypub.py @@ -292,3 +292,20 @@ def follower_collection(domain, collection): } logger.info(f'Returning {json_dumps(collection, indent=2)}') return collection, {'Content-Type': as2.CONTENT_TYPE} + + +@app.get(f'//outbox') +def outbox(domain): + url = common.host_url(f"{domain}/outbox") + return { + '@context': 'https://www.w3.org/ns/activitystreams', + 'id': url, + 'summary': f"{domain}'s outbox", + 'type': 'OrderedCollection', + 'totalItems': 0, + 'first': { + 'type': 'CollectionPage', + 'partOf': url, + 'items': [], + }, + }, {'Content-Type': as2.CONTENT_TYPE} diff --git a/tests/test_activitypub.py b/tests/test_activitypub.py index 365233a..4f0bfe6 100644 --- a/tests/test_activitypub.py +++ b/tests/test_activitypub.py @@ -816,3 +816,20 @@ class ActivityPubTest(testutil.TestCase): 'next': f'http://localhost/foo.com/following?before={after}', 'items': [ACTOR], }, resp.json) + + + def test_outbox_empty(self, _, mock_get, __): + resp = self.client.get(f'/foo.com/outbox') + self.assertEqual(200, resp.status_code) + self.assertEqual({ + '@context': 'https://www.w3.org/ns/activitystreams', + 'id': 'http://localhost/foo.com/outbox', + 'summary': "foo.com's outbox", + 'type': 'OrderedCollection', + 'totalItems': 0, + 'first': { + 'type': 'CollectionPage', + 'partOf': 'http://localhost/foo.com/outbox', + 'items': [], + }, + }, resp.json)