kopia lustrzana https://github.com/snarfed/bridgy-fed
rodzic
579f55d965
commit
33c5c3a4d2
|
@ -875,7 +875,8 @@ def inbox(protocol=None, id=None):
|
|||
# source protocol in path; primarily for backcompat
|
||||
@app.get(f'/ap/web/<regex("{DOMAIN_RE}"):id>/<any(followers,following):collection>')
|
||||
# special case Web users without /ap/web/ prefix, for backward compatibility
|
||||
@app.get(f'/<regex("{DOMAIN_RE}"):id>/<any(followers,following):collection>')
|
||||
@app.route(f'/<regex("{DOMAIN_RE}"):id>/<any(followers,following):collection>',
|
||||
methods=['GET', 'HEAD'])
|
||||
@flask_util.cached(cache, CACHE_TIME)
|
||||
def follower_collection(id, collection):
|
||||
"""ActivityPub Followers and Following collections.
|
||||
|
@ -892,6 +893,9 @@ def follower_collection(id, collection):
|
|||
if not user:
|
||||
return f'{protocol} user {id} not found', 404
|
||||
|
||||
if request.method == 'HEAD':
|
||||
return '', {'Content-Type': as2.CONTENT_TYPE}
|
||||
|
||||
# page
|
||||
followers, new_before, new_after = Follower.fetch_page(collection, user=user)
|
||||
page = {
|
||||
|
@ -931,7 +935,7 @@ def follower_collection(id, collection):
|
|||
# source protocol in path; primarily for backcompat
|
||||
@app.get(f'/ap/web/<regex("{DOMAIN_RE}"):id>/outbox')
|
||||
# special case Web users without /ap/web/ prefix, for backward compatibility
|
||||
@app.get(f'/<regex("{DOMAIN_RE}"):id>/outbox')
|
||||
@app.route(f'/<regex("{DOMAIN_RE}"):id>/outbox', methods=['GET', 'HEAD'])
|
||||
@flask_util.cached(cache, CACHE_TIME)
|
||||
def outbox(id):
|
||||
"""Serves a user's AP outbox.
|
||||
|
@ -946,6 +950,9 @@ def outbox(id):
|
|||
if not g.user:
|
||||
error(f'User {id} not found', status=404)
|
||||
|
||||
if request.method == 'HEAD':
|
||||
return '', {'Content-Type': as2.CONTENT_TYPE}
|
||||
|
||||
query = Object.query(Object.users == g.user.key)
|
||||
objects, new_before, new_after = fetch_objects(query, by=Object.updated,
|
||||
user=g.user)
|
||||
|
|
|
@ -1558,6 +1558,11 @@ class ActivityPubTest(TestCase):
|
|||
'items': [ACTOR],
|
||||
}, resp.json)
|
||||
|
||||
def test_following_collection_head(self, *_):
|
||||
resp = self.client.head(f'/user.com/following')
|
||||
self.assertEqual(200, resp.status_code)
|
||||
self.assertEqual('', resp.get_data(as_text=True))
|
||||
|
||||
def test_outbox_fake_empty(self, *_):
|
||||
self.make_user('fake:foo', cls=Fake)
|
||||
resp = self.client.get(f'/ap/fake:foo/outbox',
|
||||
|
@ -1641,6 +1646,11 @@ class ActivityPubTest(TestCase):
|
|||
},
|
||||
}, resp.json)
|
||||
|
||||
def test_outbox_web_head(self, *_):
|
||||
resp = self.client.head(f'/user.com/outbox')
|
||||
self.assertEqual(200, resp.status_code)
|
||||
self.assertEqual('', resp.get_data(as_text=True))
|
||||
|
||||
|
||||
class ActivityPubUtilsTest(TestCase):
|
||||
def setUp(self):
|
||||
|
|
Ładowanie…
Reference in New Issue