From 393605bde95bb816643e59eb65a33fbb25f17c51 Mon Sep 17 00:00:00 2001 From: Ryan Barrett Date: Tue, 16 Apr 2024 11:52:50 -0700 Subject: [PATCH] change ATProto.ABBREV to bsky MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤞, for #961 --- atproto.py | 9 +++++++-- models.py | 2 +- protocol.py | 2 +- templates/docs.html | 1 + tests/test_activitypub.py | 4 ++-- tests/test_atproto.py | 30 +++++++++++++++--------------- tests/test_common.py | 6 +++--- tests/test_ids.py | 12 ++++++------ tests/test_integrations.py | 14 +++++++------- tests/test_models.py | 2 +- tests/test_protocol.py | 2 +- tests/test_web.py | 2 +- 12 files changed, 46 insertions(+), 40 deletions(-) diff --git a/atproto.py b/atproto.py index bf3050d..8f8fb12 100644 --- a/atproto.py +++ b/atproto.py @@ -86,11 +86,16 @@ class ATProto(User, Protocol): Key id is DID, currently either did:plc or did:web. https://atproto.com/specs/did """ - ABBREV = 'atproto' + ABBREV = 'bsky' # TODO: add second bsky label? inject into PROTOCOLS? PHRASE = 'Bluesky' LOGO_HTML = '' - PDS_URL = f'https://{ABBREV}{common.SUPERDOMAIN}/' + # 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. + # TODO: switch to bsky.brid.gy once they lift their federation limits? we'd + # need to update serviceEndpoint in all users' DID docs. :/ + PDS_URL = f'https://atproto{common.SUPERDOMAIN}/' CONTENT_TYPE = 'application/json' def _pre_put_hook(self): diff --git a/models.py b/models.py index 5b040d0..a6f8095 100644 --- a/models.py +++ b/models.py @@ -921,7 +921,7 @@ class Object(StringIdModel): original objects in their source protocol, eg ``at://did:plc:abc/app.bsky.feed.post/123`` => ``https://mas.to/@user/456``. * Bridgy Fed subdomain URLs to the ids embedded inside them, eg - ``https://atproto.brid.gy/ap/did:plc:xyz`` => ``did:plc:xyz`` + ``https://bsky.brid.gy/ap/did:plc:xyz`` => ``did:plc:xyz`` * ATProto bsky.app URLs to their DIDs or `at://` URIs, eg ``https://bsky.app/profile/a.com`` => ``did:plc:123`` diff --git a/protocol.py b/protocol.py index 47a0604..97a21e9 100644 --- a/protocol.py +++ b/protocol.py @@ -497,7 +497,7 @@ class Protocol: For example, if ``proto`` is :class:`ActivityPub`, the ATProto URI ``at://did:plc:abc/coll/123`` will be converted to - ``https://atproto.brid.gy/ap/at://did:plc:abc/coll/123``. + ``https://bsky.brid.gy/ap/at://did:plc:abc/coll/123``. Wraps these AS1 fields: diff --git a/templates/docs.html b/templates/docs.html index 8e6b45a..78e018b 100644 --- a/templates/docs.html +++ b/templates/docs.html @@ -1,3 +1,4 @@ + {% extends "base.html" %} {% block content %} diff --git a/tests/test_activitypub.py b/tests/test_activitypub.py index 2894dd1..84c0b15 100644 --- a/tests/test_activitypub.py +++ b/tests/test_activitypub.py @@ -440,7 +440,7 @@ class ActivityPubTest(TestCase): def test_actor_atproto_not_enabled(self, *_): self.store_object(id='did:plc:user', raw={'foo': 'baz'}) self.make_user('did:plc:user', cls=ATProto) - got = self.client.get('/ap/did:plc:user', base_url='https://atproto.brid.gy/') + got = self.client.get('/ap/did:plc:user', base_url='https://bsky.brid.gy/') self.assertEqual(400, got.status_code) @patch('common.ENABLED_BRIDGES', new=[('activitypub', 'atproto')]) @@ -453,7 +453,7 @@ class ActivityPubTest(TestCase): self.make_user('did:plc:user', cls=ATProto) - got = self.client.get('/ap/did:plc:user', base_url='https://atproto.brid.gy/') + got = self.client.get('/ap/did:plc:user', base_url='https://bsky.brid.gy/') self.assertEqual(200, got.status_code) self.assertNotIn('preferredUsername', got.json) diff --git a/tests/test_atproto.py b/tests/test_atproto.py index 1b1ee2b..34a47fb 100644 --- a/tests/test_atproto.py +++ b/tests/test_atproto.py @@ -73,7 +73,7 @@ class ATProtoTest(TestCase): protocol='atproto')]) did_doc = copy.deepcopy(DID_DOC) - did_doc['service'][0]['serviceEndpoint'] = 'https://atproto.brid.gy/' + did_doc['service'][0]['serviceEndpoint'] = ATProto.PDS_URL self.store_object(id='did:plc:user', raw=did_doc) Repo.create(self.storage, 'did:plc:user', signing_key=ATPROTO_KEY) @@ -639,11 +639,11 @@ class ATProtoTest(TestCase): user = self.make_user('did:plc:user', cls=ATProto) # TODO? or remove? - # self.assertEqual('@did:plc:user@atproto.brid.gy', + # self.assertEqual('@did:plc:user@bsky.brid.gy', # user.handle_as('activitypub')) self.store_object(id='did:plc:user', raw=DID_DOC) - self.assertEqual('@han.dull@atproto.brid.gy', user.handle_as('activitypub')) + self.assertEqual('@han.dull@bsky.brid.gy', user.handle_as('activitypub')) @patch('requests.get', return_value=requests_response(DID_DOC)) def test_profile_id(self, mock_get): @@ -711,7 +711,7 @@ class ATProtoTest(TestCase): 'actor': 'fake:user', }) - self.assertTrue(ATProto.send(obj, 'https://atproto.brid.gy/')) + self.assertTrue(ATProto.send(obj, 'https://bsky.brid.gy/')) # check DID doc user = user.key.get() @@ -775,7 +775,7 @@ class ATProtoTest(TestCase): Fake.fetchable = {'fake:user': ACTOR_AS} obj = self.store_object(id='fake:post', source_protocol='fake', our_as1=NOTE_AS) - self.assertTrue(ATProto.send(obj, 'https://atproto.brid.gy/')) + self.assertTrue(ATProto.send(obj, 'https://bsky.brid.gy/')) # check profile, record user = Fake.get_by_id('fake:user') @@ -812,7 +812,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://atproto.brid.gy/')) + self.assertTrue(ATProto.send(obj, 'https://bsky.brid.gy/')) # check repo, record did = user.key.get().get_copy(ATProto) @@ -841,7 +841,7 @@ class ATProtoTest(TestCase): 'verb': 'update', 'object': note.our_as1, }) - self.assertTrue(ATProto.send(update, 'https://atproto.brid.gy/')) + self.assertTrue(ATProto.send(update, 'https://bsky.brid.gy/')) # check repo, record did = self.user.key.get().get_copy(ATProto) @@ -863,7 +863,7 @@ class ATProtoTest(TestCase): 'actor': 'fake:user', 'object': 'fake:post', }) - self.assertTrue(ATProto.send(update, 'https://atproto.brid.gy/')) + self.assertTrue(ATProto.send(update, 'https://bsky.brid.gy/')) # check repo, record did = self.user.key.get().get_copy(ATProto) @@ -895,7 +895,7 @@ class ATProtoTest(TestCase): 'actor': 'fake:user', 'object': 'at://did:plc:bob/app.bsky.feed.post/tid', }) - self.assertTrue(ATProto.send(like_obj, 'https://atproto.brid.gy/')) + self.assertTrue(ATProto.send(like_obj, 'https://bsky.brid.gy/')) # check repo, record did = user.get_copy(ATProto) @@ -935,7 +935,7 @@ class ATProtoTest(TestCase): 'actor': 'fake:user', 'object': 'at://did:bob/app.bsky.feed.post/tid', }) - self.assertTrue(ATProto.send(obj, 'https://atproto.brid.gy/')) + self.assertTrue(ATProto.send(obj, 'https://bsky.brid.gy/')) # check repo, record did = user.get_copy(ATProto) @@ -970,7 +970,7 @@ class ATProtoTest(TestCase): 'actor': 'fake:user', 'object': 'did:plc:bob', }) - self.assertTrue(ATProto.send(obj, 'https://atproto.brid.gy/')) + self.assertTrue(ATProto.send(obj, 'https://bsky.brid.gy/')) # check repo, record did = user.get_copy(ATProto) @@ -1005,7 +1005,7 @@ class ATProtoTest(TestCase): 'actor': 'fake:alice', 'object': 'fake:follow', }) - self.assertFalse(ATProto.send(obj, 'https://atproto.brid.gy/')) + self.assertFalse(ATProto.send(obj, 'https://bsky.brid.gy/')) self.assertEqual(0, AtpBlock.query().count()) self.assertEqual(0, AtpRepo.query().count()) mock_create_task.assert_not_called() @@ -1017,7 +1017,7 @@ class ATProtoTest(TestCase): copies=[Target(uri='did:plc:user', protocol='atproto')]) obj = self.store_object(id='fake:post', source_protocol='fake', our_as1=NOTE_AS) - self.assertFalse(ATProto.send(obj, 'https://atproto.brid.gy/')) + self.assertFalse(ATProto.send(obj, 'https://bsky.brid.gy/')) self.assertEqual(0, AtpBlock.query().count()) self.assertEqual(0, AtpRepo.query().count()) mock_create_task.assert_not_called() @@ -1035,7 +1035,7 @@ class ATProtoTest(TestCase): 'actor': 'fake:user', }, }) - self.assertFalse(ATProto.send(obj, 'https://atproto.brid.gy/')) + self.assertFalse(ATProto.send(obj, 'https://bsky.brid.gy/')) self.assertEqual(0, AtpBlock.query().count()) self.assertEqual(0, AtpRepo.query().count()) mock_create_task.assert_not_called() @@ -1079,7 +1079,7 @@ class ATProtoTest(TestCase): create = self.store_object(id='fake:reply:post', source_protocol='fake', our_as1=create_as1) - self.assertTrue(ATProto.send(create, 'https://atproto.brid.gy/')) + self.assertTrue(ATProto.send(create, 'https://bsky.brid.gy/')) repo = self.storage.load_repo(user.get_copy(ATProto)) last_tid = arroba.util.int_to_tid(arroba.util._tid_ts_last) diff --git a/tests/test_common.py b/tests/test_common.py index 73423e6..f74823b 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -64,7 +64,7 @@ class CommonTest(TestCase): for input, expected in [ ('https://fa.brid.gy/', ''), ('https://fa.brid.gy/ap/fake:foo', 'fake:foo'), - ('https://atproto.brid.gy/convert/ap/did:plc:123', 'did:plc:123'), + ('https://bsky.brid.gy/convert/ap/did:plc:123', 'did:plc:123'), ]: self.assertEqual(expected, common.unwrap(input)) @@ -99,8 +99,8 @@ class CommonTest(TestCase): with app.test_request_context(base_url='http://bridgy-federated.uc.r.appspot.com'): self.assertEqual('https://fed.brid.gy/asdf', common.host_url('asdf')) - with app.test_request_context(base_url='https://atproto.brid.gy', path='/foo'): - self.assertEqual('https://atproto.brid.gy/asdf', common.host_url('asdf')) + with app.test_request_context(base_url='https://bsky.brid.gy', path='/foo'): + self.assertEqual('https://bsky.brid.gy/asdf', common.host_url('asdf')) def test_is_enabled(self): self.assertTrue(common.is_enabled(Web, ActivityPub)) diff --git a/tests/test_ids.py b/tests/test_ids.py index 3c6e746..3914951 100644 --- a/tests/test_ids.py +++ b/tests/test_ids.py @@ -40,8 +40,8 @@ class IdsTest(TestCase): (ATProto, 'did:plc:456', ActivityPub, 'https://inst/user'), (ATProto, 'did:plc:789', Fake, 'fake:user'), # no copies - (ATProto, 'did:plc:x', Web, 'https://atproto.brid.gy/web/did:plc:x'), - (ATProto, 'did:plc:x', ActivityPub, 'https://atproto.brid.gy/ap/did:plc:x'), + (ATProto, 'did:plc:x', Web, 'https://bsky.brid.gy/web/did:plc:x'), + (ATProto, 'did:plc:x', ActivityPub, 'https://bsky.brid.gy/ap/did:plc:x'), (ATProto, 'did:plc:x', Fake, 'fake:u:did:plc:x'), (ATProto, 'https://bsky.app/profile/user.com', ATProto, 'did:plc:123'), (ATProto, 'https://bsky.app/profile/did:plc:123', ATProto, 'did:plc:123'), @@ -111,7 +111,7 @@ class IdsTest(TestCase): (ActivityPub, '@user@instance', Fake, 'fake:handle:@user@instance'), (ActivityPub, '@user@instance', Web, 'https://instance/@user'), - (ATProto, 'user.com', ActivityPub, '@user.com@atproto.brid.gy'), + (ATProto, 'user.com', ActivityPub, '@user.com@bsky.brid.gy'), (ATProto, 'user.com', ATProto, 'user.com'), (ATProto, 'user.com', Fake, 'fake:handle:user.com'), (ATProto, 'user.com', Web, 'user.com'), @@ -165,9 +165,9 @@ class IdsTest(TestCase): (ATProto, 'at://did/ap/post', ActivityPub, 'https://inst/post'), (ATProto, 'at://did/fa/post', Fake, 'fake:post'), # no copies - (ATProto, 'did:plc:x', Web, 'https://atproto.brid.gy/convert/web/did:plc:x'), - (ATProto, 'did:plc:x', ActivityPub, 'https://atproto.brid.gy/convert/ap/did:plc:x'), - (ATProto, 'did:plc:x', Fake, 'fake:o:atproto:did:plc:x'), + (ATProto, 'did:plc:x', Web, 'https://bsky.brid.gy/convert/web/did:plc:x'), + (ATProto, 'did:plc:x', ActivityPub, 'https://bsky.brid.gy/convert/ap/did:plc:x'), + (ATProto, 'did:plc:x', Fake, 'fake:o:bsky:did:plc:x'), (ATProto, 'https://bsky.app/profile/user.com/post/456', ATProto, 'at://did:plc:123/app.bsky.feed.post/456'), (ATProto, 'https://bsky.app/profile/did:plc:123/post/456', diff --git a/tests/test_integrations.py b/tests/test_integrations.py index 592fea5..88703d8 100644 --- a/tests/test_integrations.py +++ b/tests/test_integrations.py @@ -110,14 +110,14 @@ class IntegrationTests(TestCase): web_test.assert_deliveries(mock_post, ['http://inst/bob/inbox'], data={ '@context': 'https://www.w3.org/ns/activitystreams', 'type': 'Create', - 'id': 'https://atproto.brid.gy/convert/ap/at://did:plc:alice/app.bsky.feed.post/456#bridgy-fed-create', - 'actor': 'https://atproto.brid.gy/ap/did:plc:alice', + 'id': 'https://bsky.brid.gy/convert/ap/at://did:plc:alice/app.bsky.feed.post/456#bridgy-fed-create', + 'actor': 'https://bsky.brid.gy/ap/did:plc:alice', 'published': '2022-01-02T03:04:05+00:00', 'object': { 'type': 'Note', - 'id': 'https://atproto.brid.gy/convert/ap/at://did:plc:alice/app.bsky.feed.post/456', + 'id': 'https://bsky.brid.gy/convert/ap/at://did:plc:alice/app.bsky.feed.post/456', 'url': 'http://localhost/r/https://bsky.app/profile/did:plc:alice/post/456', - 'attributedTo': 'https://atproto.brid.gy/ap/did:plc:alice', + 'attributedTo': 'https://bsky.brid.gy/ap/did:plc:alice', 'content': 'I hereby reply', 'contentMap': {'en': 'I hereby reply'}, 'inReplyTo': 'http://inst/post', @@ -178,7 +178,7 @@ class IntegrationTests(TestCase): self.assert_req(mock_get, 'https://bob.com/') self.assert_req(mock_post, 'https://bob.com/webmention', data={ - 'source': 'https://atproto.brid.gy/convert/web/at://did:plc:alice/app.bsky.graph.follow/123', + 'source': 'https://bsky.brid.gy/convert/web/at://did:plc:alice/app.bsky.graph.follow/123', 'target': 'https://bob.com/', }, allow_redirects=False, headers={'Accept': '*/*'}) @@ -306,7 +306,7 @@ class IntegrationTests(TestCase): }) bob_did_doc = copy.deepcopy(test_atproto.DID_DOC) - bob_did_doc['service'][0]['serviceEndpoint'] = 'https://atproto.brid.gy/' + bob_did_doc['service'][0]['serviceEndpoint'] = ATProto.PDS_URL bob_did_doc.update({ 'id': 'did:plc:bob', 'alsoKnownAs': ['at://bob.inst.ap.brid.gy'], @@ -321,7 +321,7 @@ class IntegrationTests(TestCase): 'type': 'Like', 'id': 'http://inst/like', 'actor': 'https://inst/bob', - 'object': 'https://atproto.brid.gy/convert/ap/at://did:plc:alice/app.bsky.feed.post/123', + 'object': 'https://bsky.brid.gy/convert/ap/at://did:plc:alice/app.bsky.feed.post/123', } resp = self.post('/ap/atproto/did:plc:alice/inbox', json=like) self.assertEqual(202, resp.status_code) diff --git a/tests/test_models.py b/tests/test_models.py index 77a9132..a211e90 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -861,7 +861,7 @@ class ObjectTest(TestCase): 'object': { 'id': 'https://web.brid.gy/fa/fake:reply', 'inReplyTo': 'https://ap.brid.gy/fa/fake:post', - 'author': 'https://atproto.brid.gy/ap/did:plc:123', + 'author': 'https://bsky.brid.gy/ap/did:plc:123', 'tags': [{ 'objectType': 'mention', 'url': 'https://ap.brid.gy/atproto/http://inst.com/@me', diff --git a/tests/test_protocol.py b/tests/test_protocol.py index 4eb4933..de60633 100644 --- a/tests/test_protocol.py +++ b/tests/test_protocol.py @@ -409,7 +409,7 @@ class ProtocolTest(TestCase): def test_targets_checks_blocklisted_per_protocol(self): """_targets should call the target protocol's is_blocklisted().""" - # non-ATProto account, ATProto target (PDS) is atproto.brid.gy + # non-ATProto account, ATProto target (PDS) is bsky.brid.gy # shouldn't be blocklisted user = self.make_user( id='fake:user', cls=Fake, diff --git a/tests/test_web.py b/tests/test_web.py index 3a54403..df66023 100644 --- a/tests/test_web.py +++ b/tests/test_web.py @@ -2552,7 +2552,7 @@ class WebUtilTest(TestCase): self.assertEqual(False, Web.owns_handle('@foo@bar.com')) self.assertEqual(False, Web.owns_handle('foo@bar.com')) self.assertEqual(False, Web.owns_handle('localhost')) - self.assertEqual(False, Web.owns_handle('atproto.brid.gy')) + self.assertEqual(False, Web.owns_handle('bsky.brid.gy')) def test_handle_to_id(self, *_): self.assertEqual('foo.com', Web.handle_to_id('foo.com'))