Skip to content

Commit

Permalink
stop unwrapping ids etc in ActivityPub.inbox, do it in Object.as1 ins…
Browse files Browse the repository at this point in the history
…tead

for #12
  • Loading branch information
snarfed committed Sep 13, 2024
1 parent c5809e4 commit cfaacb8
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 14 deletions.
2 changes: 1 addition & 1 deletion activitypub.py
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,7 @@ def inbox(protocol=None, id=None):
id = f'{actor_id}#{type}-{object.get("id", "")}-{util.now().isoformat()}'

try:
obj = Object.get_or_create(id=id, as2=unwrap(activity), authed_as=authed_as,
obj = Object.get_or_create(id=id, as2=activity, authed_as=authed_as,
source_protocol=ActivityPub.LABEL)
except AssertionError as e:
error(f'Invalid activity, probably due to id: {e}', status=400)
Expand Down
2 changes: 1 addition & 1 deletion models.py
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ def use_urls_as_ids(obj):
use_urls_as_ids(obj)

elif self.as2:
obj = as2.to_as1(self.as2)
obj = as2.to_as1(unwrap(self.as2))

elif self.bsky:
owner, _, _ = parse_at_uri(self.key.id())
Expand Down
2 changes: 1 addition & 1 deletion tests/test_activitypub.py
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ def test_repost_of_indieweb(self, mock_head, mock_get, mock_post):
as2={
**REPOST,
'actor': ACTOR,
'object': orig_url,
'object': repost['object'],
},
users=[self.swentel_key],
delivered=['https://user.com/orig'],
Expand Down
6 changes: 1 addition & 5 deletions tests/test_integrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,7 @@ def test_activitypub_like_of_atproto(self, mock_get, _):
self.assertEqual(202, resp.status_code)

# check results
self.assertEqual({
**like,
# TODO: stop normalizing this in the original protocol's data
'object': 'at://did:plc:alice/app.bsky.feed.post/123',
}, Object.get_by_id('http://inst/like').as2)
self.assertEqual(like, Object.get_by_id('http://inst/like').as2)

repo = self.storage.load_repo('did:plc:bob')

Expand Down
6 changes: 0 additions & 6 deletions tests/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -3100,12 +3100,6 @@ def test_send_no_endpoint(self, mock_get, mock_post):
self.assert_req(mock_get, 'https://user.com/post')
mock_post.assert_not_called()

def test_send_skips_accept_follow(self, mock_get, mock_post):
obj = Object(id='https://user.com/accept', as2=test_activitypub.ACCEPT)
self.assertFalse(Web.send(obj, 'https://user.com/'))
mock_get.assert_not_called()
mock_post.assert_not_called()

def test_send_skips_add_to_collection(self, mock_get, mock_post):
obj = Object(id='fake:add', source_protocol='fake', as2={
'type': 'Add',
Expand Down

0 comments on commit cfaacb8

Please sign in to comment.