user page bug fix, handle AS1 inner objects with composite url values

fixes https://console.cloud.google.com/errors/detail/CNGc5drA4f7uOA;time=P30D?project=bridgy-federated
pull/445/head
Ryan Barrett 2023-03-23 22:04:09 -07:00
rodzic 78cef17c9a
commit 6dc4705a56
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
2 zmienionych plików z 17 dodań i 2 usunięć

Wyświetl plik

@ -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',

Wyświetl plik

@ -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'