Protocol.receive: wrap bare actor object in update activity

pull/968/head
Ryan Barrett 2024-04-22 18:39:27 -07:00
rodzic 0b00e6eb4b
commit 03b0f54cfe
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
2 zmienionych plików z 38 dodań i 2 usunięć

Wyświetl plik

@ -989,7 +989,7 @@ class Protocol:
Returns:
models.Object: ``obj`` if it's an activity, otherwise a new object
"""
if obj.type not in ('note', 'article', 'comment'):
if obj.type not in set(('note', 'article', 'comment')) | as1.ACTOR_TYPES:
return obj
obj_actor = as1.get_owner(obj.as1)

Wyświetl plik

@ -789,7 +789,6 @@ class ProtocolReceiveTest(TestCase):
def test_update_post_bare_object(self):
self.make_followers()
# post has no author
post_as1 = {
'id': 'fake:post',
'objectType': 'note',
@ -1293,6 +1292,43 @@ class ProtocolReceiveTest(TestCase):
self.assertEqual([(update_obj.key.id(), 'shared:target')], Fake.sent)
def test_update_profile_bare_object(self):
self.make_followers()
actor = {
'objectType': 'person',
'id': 'fake:user',
'displayName': 'Ms. ☕ Baz',
'summary': 'first',
}
self.store_object(id='fake:user', our_as1=actor)
actor['summary'] = 'second'
Fake.receive_as1(actor)
# profile object
actor['updated'] = '2022-01-02T03:04:05+00:00'
self.assert_object('fake:user', our_as1=actor, type='person')
# update activity
id = 'fake:user#bridgy-fed-update-2022-01-02T03:04:05+00:00'
update_obj = self.assert_object(
id,
users=[self.user.key],
status='complete',
our_as1={
'objectType': 'activity',
'verb': 'update',
'id': id,
'actor': actor,
'object': actor,
},
delivered=['shared:target'],
type='update',
object_ids=['fake:user'],
)
self.assertEqual([(id, 'shared:target')], Fake.sent)
def test_mention_object(self, *mocks):
self.alice.obj.our_as1 = {'id': 'fake:alice', 'objectType': 'person'}
self.alice.obj.put()