Skip to content

Commit

Permalink
ActivityPub.convert: omit acct: URIs
Browse files Browse the repository at this point in the history
  • Loading branch information
snarfed committed Nov 29, 2023
1 parent 911814d commit e079cec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion activitypub.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ def postprocess_as2_actor(actor, user=None):
assert isinstance(actor, dict)

url = user.web_url()
urls = util.get_list(actor, 'url')
urls = [u for u in util.get_list(actor, 'url') if u and not u.startswith('acct:')]
if not urls and url:
urls = [url]
if urls:
Expand Down
7 changes: 7 additions & 0 deletions tests/test_activitypub.py
Original file line number Diff line number Diff line change
Expand Up @@ -1852,6 +1852,13 @@ def test_postprocess_as2_actor_url_attachments(self):
'value': '<a rel="me" href="https://two"><span class="invisible">https://</span>two</a>',
}], got['attachment'])

def test_postprocess_as2_actor_strips_acct_url(self):
self.assert_equals('http://localhost/r/http://user.com/',
postprocess_as2_actor(as2.from_as1({
'objectType': 'person',
'urls': ['http://user.com/', 'acct:foo@bar'],
}), user=self.user)['url'])

def test_postprocess_as2_actor_preserves_preferredUsername(self):
# preferredUsername stays y.z despite user's username. since Mastodon
# queries Webfinger for [email protected]
Expand Down

0 comments on commit e079cec

Please sign in to comment.