diff --git a/pages.py b/pages.py index 0704668..4834b76 100644 --- a/pages.py +++ b/pages.py @@ -222,9 +222,11 @@ def fetch_objects(query): content = (inner_obj.get('content') or inner_obj.get('displayName') or inner_obj.get('summary')) - url = util.get_first(inner_obj, 'url') or inner_obj.get('id') + urls = as1.object_urls(inner_obj) + id = common.redirect_unwrap(inner_obj.get('id', '')) + url = urls[0] if urls else id if (type == 'update' and obj.domains and - inner_obj.get('id', '').strip('/') == f'https://{obj.domains[0]}'): + id.strip('/') == f'https://{obj.domains[0]}'): obj.phrase = 'updated' obj.as1.update({ 'content': 'their profile', diff --git a/tests/test_pages.py b/tests/test_pages.py index 89e578e..2007d32 100644 --- a/tests/test_pages.py +++ b/tests/test_pages.py @@ -63,6 +63,19 @@ class PagesTest(testutil.TestCase): got = self.client.get('/user/user.com') self.assert_equals(200, got.status_code) + def test_user_object_url_object(self): + with app.test_request_context('/'): + Object(id='a', domains=['user.com'], labels=['notification'], our_as1={ + **REPOST_AS2, + 'object': { + 'id': 'https://mas.to/toot/id', + 'url': {'value': 'http://foo', 'displayName': 'bar'}, + }, + }).put() + + got = self.client.get('/user/user.com') + self.assert_equals(200, got.status_code) + @patch('requests.get') def test_check_web_site(self, mock_get): redir = 'http://localhost/.well-known/webfinger?resource=acct:orig@orig'