kopia lustrzana https://github.com/snarfed/bridgy-fed
rodzic
42eb6b1d8b
commit
84324c0c0b
11
protocol.py
11
protocol.py
|
@ -956,10 +956,14 @@ class Protocol:
|
|||
|
||||
orig_obj = None
|
||||
targets = {} # maps Target to Object or None
|
||||
in_reply_to = as1.get_object(obj.as1).get('inReplyTo')
|
||||
is_self_reply = False
|
||||
owner = as1.get_owner(obj.as1)
|
||||
|
||||
in_reply_to_owner = None
|
||||
if in_reply_to := as1.get_object(obj.as1).get('inReplyTo'):
|
||||
if in_reply_to_obj := Protocol.for_id(in_reply_to).load(in_reply_to):
|
||||
in_reply_to_owner = as1.get_owner(in_reply_to_obj.as1)
|
||||
is_self_reply = False
|
||||
|
||||
for id in sorted(target_uris):
|
||||
protocol = Protocol.for_id(id)
|
||||
if not protocol:
|
||||
|
@ -971,6 +975,9 @@ class Protocol:
|
|||
elif protocol.is_blocklisted(id):
|
||||
logger.info(f'{id} is blocklisted')
|
||||
continue
|
||||
elif id == in_reply_to_owner:
|
||||
logger.info(f'Skipping mention of in-reply-to author')
|
||||
continue
|
||||
|
||||
orig_obj = protocol.load(id)
|
||||
if not orig_obj or not orig_obj.as1:
|
||||
|
|
|
@ -864,6 +864,41 @@ class ProtocolReceiveTest(TestCase):
|
|||
(obj.key.id(), 'other:eve:target'),
|
||||
], OtherFake.sent)
|
||||
|
||||
def test_reply_skips_mention_of_original_post_author(self):
|
||||
bob = self.store_object(id='fake:bob', our_as1={'foo': 1})
|
||||
eve = self.store_object(id='fake:eve', our_as1={'foo': 2})
|
||||
|
||||
reply_as1 = {
|
||||
'id': 'other:reply',
|
||||
'objectType': 'note',
|
||||
'inReplyTo': 'fake:post',
|
||||
'author': 'other:alice',
|
||||
'content': 'foo',
|
||||
'tags': [{
|
||||
'objectType': 'mention',
|
||||
'url': 'fake:eve',
|
||||
}, {
|
||||
'objectType': 'mention',
|
||||
'url': 'fake:bob',
|
||||
}],
|
||||
}
|
||||
Fake.fetchable = {
|
||||
'fake:post': {
|
||||
'objectType': 'note',
|
||||
'id': 'fake:post',
|
||||
'author': 'fake:bob',
|
||||
},
|
||||
}
|
||||
self.assertEqual(('OK', 202), Fake.receive_as1(reply_as1))
|
||||
|
||||
obj = Object.get_by_id('other:reply#bridgy-fed-create')
|
||||
self.assertEqual([Fake(id='fake:bob').key], obj.notify)
|
||||
self.assertEqual([
|
||||
# bob shouldn't be here, we should suppress the mention
|
||||
(obj.key.id(), 'fake:eve:target'),
|
||||
(obj.key.id(), 'fake:post:target'),
|
||||
], Fake.sent)
|
||||
|
||||
def test_update_reply(self):
|
||||
self.make_followers()
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue