Protocol.receive: always wrap actor objects in update, not post/create

pull/977/head
Ryan Barrett 2024-04-25 13:45:27 -07:00
rodzic 8fe2bb47f6
commit 1d20befe7e
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
3 zmienionych plików z 11 dodań i 6 usunięć

Wyświetl plik

@ -1005,15 +1005,17 @@ class Protocol:
Returns:
models.Object: ``obj`` if it's an activity, otherwise a new object
"""
if obj.type not in set(('note', 'article', 'comment')) | as1.ACTOR_TYPES:
is_actor = obj.type in as1.ACTOR_TYPES
if not is_actor and obj.type not in ('note', 'article', 'comment'):
return obj
obj_actor = as1.get_owner(obj.as1)
now = util.now().isoformat()
# this is a raw post; wrap it in a create or update activity
if obj.changed:
logger.info(f'Content has changed from last time at {obj.updated}! Redelivering to all inboxes')
if obj.changed or is_actor:
if obj.changed:
logger.info(f'Content has changed from last time at {obj.updated}! Redelivering to all inboxes')
id = f'{obj.key.id()}#bridgy-fed-update-{now}'
update_as1 = {
'objectType': 'activity',

Wyświetl plik

@ -184,6 +184,8 @@ class PagesTest(TestCase):
get_flashed_messages())
self.assertEqual(['fake:user'], Fake.fetched)
actor['updated'] = '2022-01-02T03:04:05+00:00'
self.assert_object('fake:user', source_protocol='fake', our_as1=actor)
def test_followers(self):

Wyświetl plik

@ -1313,15 +1313,16 @@ class ProtocolReceiveTest(TestCase):
def test_update_profile_bare_object(self):
self.make_followers()
actor = {
actor = self.user.obj.our_as1 = {
'objectType': 'person',
'id': 'fake:user',
'displayName': 'Ms. ☕ Baz',
'summary': 'first',
}
self.store_object(id='fake:user', our_as1=actor)
self.user.obj.put()
actor['summary'] = 'second'
# unchanged from what's already in the datastore. we should send update
# anyway (instead of create) since it's an actor.
Fake.receive_as1(actor)
# profile object