kopia lustrzana https://github.com/snarfed/bridgy-fed
Protocol.receive: always wrap actor objects in update, not post/create
rodzic
8fe2bb47f6
commit
1d20befe7e
|
@ -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',
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
|
Ładowanie…
Reference in New Issue