Skip to content

Commit

Permalink
AP: always populate inbox and outbox in actors
Browse files Browse the repository at this point in the history
  • Loading branch information
snarfed committed Aug 19, 2023
1 parent f8a1ac4 commit 6cddd95
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions activitypub.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,10 @@ def postprocess_as2_actor(actor, wrap=True):

actor.update({
'url': urls if len(urls) > 1 else urls[0],
# required by ActivityPub
# https://www.w3.org/TR/activitypub/#actor-objects
'inbox': g.user.ap_actor('inbox'),
'outbox': g.user.ap_actor('outbox'),
# This has to be the domain for Mastodon interop/Webfinger discovery!
# See related comment in actor() below.
'preferredUsername': domain,
Expand Down
1 change: 0 additions & 1 deletion models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import random
from urllib.parse import quote, urlparse

from arroba.mst import dag_cbor_cid
from Crypto.PublicKey import ECC, RSA
import dag_json
from flask import g, request
Expand Down
6 changes: 6 additions & 0 deletions tests/test_activitypub.py
Original file line number Diff line number Diff line change
Expand Up @@ -1535,15 +1535,21 @@ def test_postprocess_as2_actor_attributedTo(self):
'id': 'baj',
'preferredUsername': 'site',
'url': 'http://localhost/r/site',
'inbox': 'http://bf/fake/site/ap/inbox',
'outbox': 'http://bf/fake/site/ap/outbox',
},
'attributedTo': [{
'id': 'bar',
'preferredUsername': 'site',
'url': 'http://localhost/r/site',
'inbox': 'http://bf/fake/site/ap/inbox',
'outbox': 'http://bf/fake/site/ap/outbox',
}, {
'id': 'baz',
'preferredUsername': 'site',
'url': 'http://localhost/r/site',
'inbox': 'http://bf/fake/site/ap/inbox',
'outbox': 'http://bf/fake/site/ap/outbox',
}],
'to': [as2.PUBLIC_AUDIENCE],
}, postprocess_as2({
Expand Down
2 changes: 0 additions & 2 deletions tests/test_redirect.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ def test_as2_no_user_fetch_homepage(self, mock_get):
del expected['endpoints']
del expected['followers']
del expected['following']
del expected['inbox']
del expected['outbox']
self.assert_equals(expected, resp.json, ignore=['publicKeyPem'])

self.assert_user(Web, 'user.com', direct=False, obj_as2={
Expand Down
2 changes: 2 additions & 0 deletions tests/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
'url': 'http://localhost/r/https://user.com/',
'name': 'Ms. ☕ Baz',
'preferredUsername': 'user.com',
'inbox': 'http://localhost/user.com/inbox',
'outbox': 'http://localhost/user.com/outbox',
}
ACTOR_AS2_USER = {
'type': 'Person',
Expand Down

0 comments on commit 6cddd95

Please sign in to comment.