kopia lustrzana https://github.com/snarfed/bridgy-fed
Protocol.receive: drop direct targets if user isn't bridged into their protocol
fixes https://console.cloud.google.com/errors/detail/CMHloZaRmPXQZQ;time=P30D?project=bridgy-federatedpull/1125/head
rodzic
9ff28ea690
commit
796edf2033
|
@ -1304,6 +1304,9 @@ class Protocol:
|
|||
elif protocol.is_blocklisted(id):
|
||||
logger.info(f'{id} is blocklisted')
|
||||
continue
|
||||
elif not from_user.is_enabled(protocol):
|
||||
logger.info(f"{from_user.key.id()} hasn't enabled {protocol.LABEL}")
|
||||
continue
|
||||
|
||||
orig_obj = protocol.load(id)
|
||||
if not orig_obj or not orig_obj.as1:
|
||||
|
|
|
@ -48,6 +48,7 @@ class IntegrationTests(TestCase):
|
|||
def make_ap_user_with_atp(self, ap_id, did):
|
||||
Repo.create(self.storage, did, signing_key=ATPROTO_KEY)
|
||||
user = self.make_user(id=ap_id, cls=ActivityPub,
|
||||
enabled_protocols=['atproto'],
|
||||
copies=[Target(uri=did, protocol='atproto')],
|
||||
obj_as2=add_key({
|
||||
'type': 'Person',
|
||||
|
@ -556,7 +557,8 @@ class IntegrationTests(TestCase):
|
|||
"""
|
||||
self.store_object(id='did:plc:alice', raw=DID_DOC)
|
||||
alice = self.make_user(id='did:plc:alice', cls=ATProto,
|
||||
obj_bsky=test_atproto.ACTOR_PROFILE_BSKY)
|
||||
obj_bsky=test_atproto.ACTOR_PROFILE_BSKY,
|
||||
enabled_protocols=['activitypub'])
|
||||
bob = self.make_ap_user_with_atp('https://inst/bob', 'did:plc:bob')
|
||||
|
||||
post = {
|
||||
|
|
|
@ -749,7 +749,7 @@ class ProtocolReceiveTest(TestCase):
|
|||
self.assertEqual([(obj.key.id(), 'shared:target')], Fake.sent)
|
||||
|
||||
@patch.object(ATProto, 'send', return_value=True)
|
||||
def test_create_post_user_enabled_atproto_adds_pds_target(self, mock_send):
|
||||
def test_post_by_user_enabled_atproto_adds_pds_target(self, mock_send):
|
||||
self.user.enabled_protocols = ['atproto']
|
||||
self.user.put()
|
||||
|
||||
|
@ -765,9 +765,9 @@ class ProtocolReceiveTest(TestCase):
|
|||
self.assertEqual(ATProto.PDS_URL, url)
|
||||
|
||||
@patch.object(ATProto, 'send', return_value=True)
|
||||
def test_create_reply_to_not_bridged_account_skips_atproto(self, mock_send):
|
||||
def test_reply_to_not_bridged_account_skips_atproto(self, mock_send):
|
||||
user = self.make_user('eefake:user', cls=ExplicitEnableFake,
|
||||
enabled_protocols = ['atproto'])
|
||||
enabled_protocols=['atproto'])
|
||||
|
||||
self.eve = self.make_user('eefake:eve', cls=ExplicitEnableFake)
|
||||
self.store_object(id='eefake:post', our_as1={
|
||||
|
@ -787,9 +787,9 @@ class ProtocolReceiveTest(TestCase):
|
|||
self.assertEqual(0, mock_send.call_count)
|
||||
|
||||
@patch.object(ATProto, 'send', return_value=True)
|
||||
def test_create_repost_of_not_bridged_account_skips_atproto(self, mock_send):
|
||||
def test_repost_of_not_bridged_account_skips_atproto(self, mock_send):
|
||||
user = self.make_user('eefake:user', cls=ExplicitEnableFake,
|
||||
enabled_protocols = ['atproto'])
|
||||
enabled_protocols=['atproto'])
|
||||
|
||||
self.eve = self.make_user('eefake:eve', cls=ExplicitEnableFake)
|
||||
self.store_object(id='eefake:post', our_as1={
|
||||
|
@ -809,6 +809,30 @@ class ProtocolReceiveTest(TestCase):
|
|||
|
||||
self.assertEqual(0, mock_send.call_count)
|
||||
|
||||
@patch.object(ATProto, 'send', return_value=True)
|
||||
def test_follow_of_bridged_account_by_not_bridged_account_skips_atproto(
|
||||
self, mock_send):
|
||||
user = self.make_user('eefake:user', cls=ExplicitEnableFake)
|
||||
self.store_object(id='did:plc:eve', raw=DID_DOC)
|
||||
eve = self.make_user('did:plc:eve', cls=ATProto, enabled_protocols=['eefake'],
|
||||
copies=[Target(uri='eefake:eve', protocol='eefake')],
|
||||
obj_bsky=ACTOR_PROFILE_BSKY)
|
||||
|
||||
with self.assertRaises(NoContent):
|
||||
ExplicitEnableFake.receive_as1({
|
||||
'id': 'eefake:follow',
|
||||
'objectType': 'activity',
|
||||
'verb': 'follow',
|
||||
'actor': 'eefake:user',
|
||||
'object': 'eefake:eve',
|
||||
})
|
||||
|
||||
self.assert_entities_equal(Follower(from_=user.key, to=eve.key,
|
||||
follow=Object(id='eefake:follow').key),
|
||||
Follower.query().fetch(),
|
||||
ignore=['created', 'updated'])
|
||||
self.assertEqual(0, mock_send.call_count)
|
||||
|
||||
@patch.object(ATProto, 'send', return_value=True)
|
||||
def test_atproto_targets_normalize_pds_url(self, mock_send):
|
||||
# we were over-normalizing our PDS URL https://atproto.brid.gy , adding
|
||||
|
|
Ładowanie…
Reference in New Issue