kopia lustrzana https://github.com/snarfed/bridgy-fed
AP: serve protocol bot users on their own subdomains
rodzic
c87e69d354
commit
0b00e6eb4b
|
@ -835,7 +835,12 @@ def postprocess_as2_actor(actor, user):
|
|||
@flask_util.cached(cache, CACHE_TIME)
|
||||
def actor(handle_or_id):
|
||||
"""Serves a user's AS2 actor from the datastore."""
|
||||
cls = Protocol.for_request(fed='web')
|
||||
if handle_or_id == PRIMARY_DOMAIN or handle_or_id in PROTOCOL_DOMAINS:
|
||||
from web import Web
|
||||
cls = Web
|
||||
else:
|
||||
cls = Protocol.for_request(fed='web')
|
||||
|
||||
if not cls:
|
||||
error(f"Couldn't determine protocol", status=404)
|
||||
elif cls.LABEL == 'web' and request.path.startswith('/ap/'):
|
||||
|
|
|
@ -495,17 +495,15 @@ class ActivityPubTest(TestCase):
|
|||
def test_actor_protocol_bot_user(self, *_):
|
||||
"""Web users are special cased to drop the /web/ prefix."""
|
||||
actor_as2 = json_loads(util.read('bsky.brid.gy.as2.json'))
|
||||
self.make_user('bsky.brid.gy', cls=Web, obj_as2=actor_as2,
|
||||
obj_id='https://bsky.brid.gy/')
|
||||
self.make_user('bsky.brid.gy', cls=Web, ap_subdomain='bsky',
|
||||
obj_as2=actor_as2, obj_id='https://bsky.brid.gy/')
|
||||
|
||||
got = self.client.get('/bsky.brid.gy')
|
||||
got = self.client.get('/bsky.brid.gy', base_url='https://bsky.brid.gy/')
|
||||
self.assertEqual(200, got.status_code)
|
||||
self.assertEqual(as2.CONTENT_TYPE_LD_PROFILE, got.headers['Content-Type'])
|
||||
self.assert_equals({
|
||||
**actor_as2,
|
||||
'id': 'http://localhost/bsky.brid.gy',
|
||||
}, got.json, ignore=['inbox', 'outbox', 'endpoints', 'followers',
|
||||
'following', 'publicKey', 'publicKeyPem'])
|
||||
self.assert_equals(actor_as2, got.json,
|
||||
ignore=['inbox', 'outbox', 'endpoints', 'followers',
|
||||
'following', 'publicKey', 'publicKeyPem'])
|
||||
|
||||
# skip _pre_put_hook since it doesn't allow internal domains
|
||||
@patch.object(Web, '_pre_put_hook', new=lambda self: None)
|
||||
|
|
Ładowanie…
Reference in New Issue