kopia lustrzana https://github.com/snarfed/bridgy-fed
Protocol.targets: bug fix for self replies
this bug snuck in because of our special case handling of Fake and OtherFake in Protocol.targets. ugh. need to get rid of that, and elsewhere, eg ids.*. fixes #1179pull/1187/head
rodzic
1f73058ef6
commit
2a83cbb0d8
|
@ -1276,7 +1276,8 @@ class Protocol:
|
||||||
to_protocols = []
|
to_protocols = []
|
||||||
if DEBUG and from_user.LABEL != 'eefake': # for unit tests
|
if DEBUG and from_user.LABEL != 'eefake': # for unit tests
|
||||||
to_protocols = [PROTOCOLS['fake'], PROTOCOLS['other']]
|
to_protocols = [PROTOCOLS['fake'], PROTOCOLS['other']]
|
||||||
for label in (list(from_user.DEFAULT_ENABLED_PROTOCOLS)
|
for label in ([from_user.LABEL]
|
||||||
|
+ list(from_user.DEFAULT_ENABLED_PROTOCOLS)
|
||||||
+ from_user.enabled_protocols):
|
+ from_user.enabled_protocols):
|
||||||
proto = PROTOCOLS[label]
|
proto = PROTOCOLS[label]
|
||||||
if proto.HAS_COPIES and (obj.type in ('update', 'delete', 'share')
|
if proto.HAS_COPIES and (obj.type in ('update', 'delete', 'share')
|
||||||
|
|
|
@ -1425,35 +1425,43 @@ class ProtocolReceiveTest(TestCase):
|
||||||
|
|
||||||
|
|
||||||
def test_create_self_reply_to_same_protocol_bridge_if_original_is_bridged(self):
|
def test_create_self_reply_to_same_protocol_bridge_if_original_is_bridged(self):
|
||||||
# eve follows alice
|
# use eefake because Protocol.targets automatically adds fake and other
|
||||||
eve = self.make_user('other:eve', cls=OtherFake, obj_id='other:eve')
|
# to to_protocols.
|
||||||
Follower.get_or_create(to=self.alice, from_=eve)
|
# TODO: refactor tests to not do fake-to-fake delivery, then remove
|
||||||
|
# these special cases
|
||||||
|
user = self.make_user('eefake:user', cls=ExplicitEnableFake,
|
||||||
|
obj_id='eefake:user', enabled_protocols=['other'])
|
||||||
|
|
||||||
# alice replies to herself
|
# eve follows user
|
||||||
self.store_object(id='fake:post', source_protocol='fake',
|
eve = self.make_user('other:eve', cls=OtherFake, obj_id='other:eve')
|
||||||
|
Follower.get_or_create(to=user, from_=eve)
|
||||||
|
|
||||||
|
# user replies to themselves
|
||||||
|
self.store_object(id='eefake:post', source_protocol='eefake',
|
||||||
copies=[Target(protocol='other', uri='other:post')],
|
copies=[Target(protocol='other', uri='other:post')],
|
||||||
our_as1={
|
our_as1={
|
||||||
'objectType': 'note',
|
'objectType': 'note',
|
||||||
'id': 'fake:post',
|
'id': 'eefake:post',
|
||||||
'author': 'fake:alice',
|
'author': 'eefake:user',
|
||||||
})
|
})
|
||||||
|
|
||||||
reply_as1 = {
|
reply_as1 = {
|
||||||
'id': 'fake:reply',
|
'id': 'eefake:reply',
|
||||||
'objectType': 'note',
|
'objectType': 'note',
|
||||||
'inReplyTo': 'fake:post',
|
'inReplyTo': 'eefake:post',
|
||||||
'author': 'fake:alice',
|
'author': 'eefake:user',
|
||||||
}
|
}
|
||||||
self.assertEqual(('OK', 202), Fake.receive_as1(reply_as1))
|
self.assertEqual(('OK', 202), ExplicitEnableFake.receive_as1(reply_as1))
|
||||||
|
|
||||||
copy = Target(protocol='other', uri='other:o:fa:fake:reply')
|
copy = Target(protocol='other', uri='other:o:eefake:eefake:reply')
|
||||||
reply = self.assert_object('fake:reply',
|
reply = self.assert_object('eefake:reply',
|
||||||
type='note',
|
type='note',
|
||||||
|
source_protocol='eefake',
|
||||||
our_as1=reply_as1,
|
our_as1=reply_as1,
|
||||||
copies=[copy],
|
copies=[copy],
|
||||||
feed=[eve.key])
|
feed=[eve.key])
|
||||||
self.assertEqual([('fake:reply#bridgy-fed-create', 'other:eve:target'),
|
self.assertEqual([('eefake:reply#bridgy-fed-create', 'other:eve:target'),
|
||||||
('fake:reply#bridgy-fed-create', 'other:post:target'),
|
('eefake:reply#bridgy-fed-create', 'other:post:target'),
|
||||||
], OtherFake.sent)
|
], OtherFake.sent)
|
||||||
|
|
||||||
def test_update_reply(self):
|
def test_update_reply(self):
|
||||||
|
|
Ładowanie…
Reference in New Issue