kopia lustrzana https://github.com/snarfed/bridgy-fed
activitypub.postprocess_as2: for Create/Update, put object's to/cc into activity
for possible Pleroma/Akkoma interop: https://git.pleroma.social/pleroma/pleroma/-/issues/3206#note_108296 https://indieweb.social/@diego@lounge.collabfc.com/112977955332152430pull/1273/head
rodzic
6ce612d83d
commit
e2b6b59ff4
|
@ -796,6 +796,14 @@ def postprocess_as2(activity, orig_obj=None, wrap=True):
|
|||
for recip in as1.get_objects(orig_obj, field):
|
||||
add(cc, util.get_url(recip) or recip.get('id'))
|
||||
|
||||
# for CRUD activities, Pleroma (and Akkoma?) seem to crash if the activity's
|
||||
# to and cc aren't exactly the same as the object's. (I think?)
|
||||
# https://indieweb.social/@diego@lounge.collabfc.com/112977955332152430
|
||||
# https://git.pleroma.social/pleroma/pleroma/-/issues/3206#note_108296
|
||||
if type in ('Create', 'Update'):
|
||||
activity['to'] = util.get_list(obj, 'to')
|
||||
activity['cc'] = util.get_list(obj, 'cc')
|
||||
|
||||
# WARNING: activity here is AS2, but we're using as1.is_dm. right now the
|
||||
# logic is effectively the same for our purposes, but watch out here if that
|
||||
# ever changes.
|
||||
|
|
|
@ -2459,6 +2459,19 @@ class ActivityPubUtilsTest(TestCase):
|
|||
self.assertEqual(['https://masto.foo/@other'],
|
||||
postprocess_as2(obj)['cc'])
|
||||
|
||||
def test_postprocess_as2_object_to_cc_into_activity(self):
|
||||
got = postprocess_as2({
|
||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||
'type': 'Create',
|
||||
'object': {
|
||||
'to': ['abc'],
|
||||
'cc': ['def', 'xyz'],
|
||||
},
|
||||
})
|
||||
self.assertEqual(['abc', 'https://www.w3.org/ns/activitystreams#Public'],
|
||||
got['to'])
|
||||
self.assertEqual(['def', 'xyz'], got['cc'])
|
||||
|
||||
def test_postprocess_as2_dm_note(self):
|
||||
dm = {
|
||||
'objectType': 'note',
|
||||
|
|
|
@ -158,6 +158,7 @@ class IntegrationTests(TestCase):
|
|||
'cc': ['http://inst/bob'],
|
||||
},
|
||||
'to': ['https://www.w3.org/ns/activitystreams#Public'],
|
||||
'cc': ['http://inst/bob'],
|
||||
})
|
||||
|
||||
|
||||
|
|
|
@ -277,6 +277,12 @@ AS2_CREATE = {
|
|||
}],
|
||||
},
|
||||
'to': [as2.PUBLIC_AUDIENCE],
|
||||
'cc': [
|
||||
'https://mas.to/author',
|
||||
'https://mas.to/bystander',
|
||||
'https://mas.to/recipient',
|
||||
as2.PUBLIC_AUDIENCE,
|
||||
],
|
||||
}
|
||||
AS2_UPDATE = copy.deepcopy(AS2_CREATE)
|
||||
AS2_UPDATE.update({
|
||||
|
|
Ładowanie…
Reference in New Issue