From e079cec77c188bbca1f58e4adb7c184a22facad7 Mon Sep 17 00:00:00 2001 From: Ryan Barrett Date: Wed, 29 Nov 2023 14:51:56 -0800 Subject: [PATCH] ActivityPub.convert: omit acct: URIs for #738, https://github.com/Automattic/wordpress-activitypub/issues/571 --- activitypub.py | 2 +- tests/test_activitypub.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/activitypub.py b/activitypub.py index b814610..4e5f6c2 100644 --- a/activitypub.py +++ b/activitypub.py @@ -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: diff --git a/tests/test_activitypub.py b/tests/test_activitypub.py index 8169e20..1f13285 100644 --- a/tests/test_activitypub.py +++ b/tests/test_activitypub.py @@ -1852,6 +1852,13 @@ class ActivityPubUtilsTest(TestCase): 'value': 'two', }], 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 preferredUsername@fed.brid.gy