From f1531b44e7c95c30c5744704a7ee028026d482c6 Mon Sep 17 00:00:00 2001 From: Ryan Barrett Date: Mon, 1 Apr 2024 23:06:25 -0700 Subject: [PATCH] bug fix for bad profile link on followers page fixes #934 --- activitypub.py | 2 +- pages.py | 1 + tests/test_activitypub.py | 13 +++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/activitypub.py b/activitypub.py index e1b41ad..d982d87 100644 --- a/activitypub.py +++ b/activitypub.py @@ -91,7 +91,7 @@ class ActivityPub(User, Protocol): def web_url(self): """Returns this user's web URL aka web_url, eg ``https://foo.com/``.""" if self.obj and self.obj.as1: - url = util.get_url(self.obj.as1) + url = as1.get_url(self.obj.as1) if url: return url diff --git a/pages.py b/pages.py index 43e23fd..d3c880c 100644 --- a/pages.py +++ b/pages.py @@ -35,6 +35,7 @@ with app.test_request_context('/'): logger = logging.getLogger(__name__) TEMPLATE_VARS = { + 'as1': as1, 'as2': as2, 'g': g, 'isinstance': isinstance, diff --git a/tests/test_activitypub.py b/tests/test_activitypub.py index daeafd5..618757b 100644 --- a/tests/test_activitypub.py +++ b/tests/test_activitypub.py @@ -2259,6 +2259,19 @@ class ActivityPubUtilsTest(TestCase): }) self.assertEqual('me.mas.to.ap.brid.gy', user.handle_as('atproto')) + def test_web_url_composite_url_object(self): + actor_as2 = { + 'type': 'Person', + 'url': 'https://techhub.social/@foo', + 'attachment': [{ + 'type': 'PropertyValue', + 'name': 'Twitter', + 'value': '@foo', + }], + } + user = self.make_user('http://foo/actor', cls=ActivityPub, obj_as2=actor_as2) + self.assertEqual('https://techhub.social/@foo', user.web_url()) + def test_web_url(self): user = self.make_user('http://foo/actor', cls=ActivityPub) self.assertEqual('http://foo/actor', user.web_url())