kopia lustrzana https://github.com/snarfed/bridgy-fed
ATProto: drop trailing slash from PDS URL
the ATProto DID spec says it shouldn't be there: https://atproto.com/specs/did#did-documents > The serviceEndpoint field must contain an HTTPS URL of server. It should contain only the URI scheme (http or https), hostname, and optional port number, not any "userinfo", path prefix, or other components. thanks for the nudge @mackuba!pull/1020/head
rodzic
38ecaf3d0b
commit
ee9bb53745
12
atproto.py
12
atproto.py
|
@ -90,8 +90,9 @@ class ATProto(User, Protocol):
|
|||
LOGO_HTML = '<img src="/oauth_dropins_static/bluesky.svg">'
|
||||
# note that PDS hostname is atproto.brid.gy here, not bsky.brid.gy. Bluesky
|
||||
# team currently has our hostname as atproto.brid.gy in their federation
|
||||
# test.
|
||||
PDS_URL = f'https://atproto{common.SUPERDOMAIN}/'
|
||||
# test. also note that PDS URL shouldn't include trailing slash.
|
||||
# https://atproto.com/specs/did#did-documents
|
||||
PDS_URL = f'https://atproto{common.SUPERDOMAIN}'
|
||||
CONTENT_TYPE = 'application/json'
|
||||
HAS_COPIES = True
|
||||
DEFAULT_ENABLED_PROTOCOLS = ()
|
||||
|
@ -254,11 +255,12 @@ class ATProto(User, Protocol):
|
|||
return
|
||||
|
||||
# create new DID, repo
|
||||
pds_url = common.host_url() if DEBUG else cls.PDS_URL
|
||||
# PDS URL shouldn't include trailing slash!
|
||||
# https://atproto.com/specs/did#did-documents
|
||||
pds_url = common.host_url().rstrip('/') if DEBUG else cls.PDS_URL
|
||||
logger.info(f'Creating new did:plc for {user.key} {pds_url}')
|
||||
did_plc = did.create_plc(user.handle_as('atproto'),
|
||||
pds_url=pds_url,
|
||||
post_fn=util.requests_post)
|
||||
pds_url=pds_url, post_fn=util.requests_post)
|
||||
|
||||
Object.get_or_create(did_plc.did, raw=did_plc.doc)
|
||||
# TODO: move this to ATProto.get_or_create?
|
||||
|
|
|
@ -1175,7 +1175,11 @@ class Protocol:
|
|||
(obj.as1.get('id'), obj.as1.get('url'), as1.get_owner(obj.as1))
|
||||
if util.is_web(url)
|
||||
]
|
||||
for url in sorted(util.dedupe_urls(candidates.keys())):
|
||||
for url in sorted(util.dedupe_urls(
|
||||
candidates.keys(),
|
||||
# preserve our PDS URL without trailing slash for path
|
||||
# https://atproto.com/specs/did#did-documents
|
||||
trailing_slash=False)):
|
||||
if util.is_web(url) and util.domain_from_link(url) in source_domains:
|
||||
logger.info(f'Skipping same-domain target {url}')
|
||||
else:
|
||||
|
|
|
@ -239,7 +239,7 @@ class ATProtoTest(TestCase):
|
|||
self.assertEqual('opt-out', user.status)
|
||||
|
||||
def test_target_for_user_no_stored_did(self):
|
||||
self.assertEqual('https://atproto.brid.gy/', ATProto.target_for(
|
||||
self.assertEqual('https://atproto.brid.gy', ATProto.target_for(
|
||||
Object(id='at://foo')))
|
||||
self.assertIsNone(ATProto.target_for(Object(id='fake:post')))
|
||||
|
||||
|
@ -720,7 +720,7 @@ class ATProtoTest(TestCase):
|
|||
assert did
|
||||
self.assertEqual([Target(uri=did, protocol='atproto')], user.copies)
|
||||
did_obj = ATProto.load(did, did_doc=True)
|
||||
self.assertEqual('http://localhost/',
|
||||
self.assertEqual('http://localhost',
|
||||
did_obj.raw['service'][0]['serviceEndpoint'])
|
||||
|
||||
# check repo, record
|
||||
|
@ -754,7 +754,7 @@ class ATProtoTest(TestCase):
|
|||
'services': {
|
||||
'atproto_pds': {
|
||||
'type': 'AtprotoPersonalDataServer',
|
||||
'endpoint': 'http://localhost/',
|
||||
'endpoint': 'http://localhost',
|
||||
}
|
||||
},
|
||||
'prev': None,
|
||||
|
@ -813,7 +813,7 @@ class ATProtoTest(TestCase):
|
|||
user = self.make_user_and_repo()
|
||||
obj = self.store_object(id='fake:post', source_protocol='fake',
|
||||
our_as1=NOTE_AS)
|
||||
self.assertTrue(ATProto.send(obj, 'https://bsky.brid.gy/'))
|
||||
self.assertTrue(ATProto.send(obj, 'https://bsky.brid.gy'))
|
||||
|
||||
# check repo, record
|
||||
did = user.key.get().get_copy(ATProto)
|
||||
|
@ -842,7 +842,7 @@ class ATProtoTest(TestCase):
|
|||
'verb': 'update',
|
||||
'object': note.our_as1,
|
||||
})
|
||||
self.assertTrue(ATProto.send(update, 'https://bsky.brid.gy/'))
|
||||
self.assertTrue(ATProto.send(update, 'https://bsky.brid.gy'))
|
||||
|
||||
# check repo, record
|
||||
did = self.user.key.get().get_copy(ATProto)
|
||||
|
@ -936,7 +936,7 @@ class ATProtoTest(TestCase):
|
|||
'actor': 'fake:user',
|
||||
'object': 'at://did:bob/app.bsky.feed.post/tid',
|
||||
})
|
||||
self.assertTrue(ATProto.send(obj, 'https://bsky.brid.gy/'))
|
||||
self.assertTrue(ATProto.send(obj, 'https://bsky.brid.gy'))
|
||||
|
||||
# check repo, record
|
||||
did = user.get_copy(ATProto)
|
||||
|
@ -971,7 +971,7 @@ class ATProtoTest(TestCase):
|
|||
'actor': 'fake:user',
|
||||
'object': 'did:plc:bob',
|
||||
})
|
||||
self.assertTrue(ATProto.send(obj, 'https://bsky.brid.gy/'))
|
||||
self.assertTrue(ATProto.send(obj, 'https://bsky.brid.gy'))
|
||||
|
||||
# check repo, record
|
||||
did = user.get_copy(ATProto)
|
||||
|
|
|
@ -241,7 +241,7 @@ class IntegrationTests(TestCase):
|
|||
# send webmention
|
||||
resp = self.post('/webmention', data={
|
||||
'source': 'https://bob.com/follow',
|
||||
'target': 'http://localhost/',
|
||||
'target': 'http://localhost',
|
||||
})
|
||||
self.assertEqual(202, resp.status_code)
|
||||
|
||||
|
|
|
@ -442,7 +442,7 @@ class ProtocolTest(TestCase):
|
|||
})
|
||||
self.assertCountEqual([
|
||||
Target(protocol='fake', uri='fake:post:target'),
|
||||
Target(protocol='atproto', uri='https://atproto.brid.gy/'),
|
||||
Target(protocol='atproto', uri='https://atproto.brid.gy'),
|
||||
], Protocol.targets(obj).keys())
|
||||
|
||||
def test_targets_composite_inreplyto(self):
|
||||
|
|
Ładowanie…
Reference in New Issue