diff --git a/tests/test_convert.py b/tests/test_convert.py index b5676db..c0643b7 100644 --- a/tests/test_convert.py +++ b/tests/test_convert.py @@ -20,7 +20,7 @@ from web import Web COMMENT_AS2 = { **as2.from_as1(COMMENT), 'type': 'Note', - 'id': 'https://web.brid.gy/r/tag:fake.com:123456', + 'id': 'https://fed.brid.gy/r/https://fake.com/123456', 'url': 'https://web.brid.gy/r/https://fake.com/123456', 'name': 'A ☕ reply', 'contentMap': {'en': COMMENT['content']}, @@ -33,7 +33,6 @@ HTML = """\
- tag:fake.com:123456 fake.com/123456
diff --git a/tests/test_web.py b/tests/test_web.py index 3374a5a..d7dfff0 100644 --- a/tests/test_web.py +++ b/tests/test_web.py @@ -2126,6 +2126,20 @@ class WebUtilTest(TestCase): 'url': 'https://user.com/post', }, obj.mf2) + def test_load_id_is_url_not_uid(self, mock_get, __): + mock_get.return_value = requests_response(NOTE_HTML.replace( + '', """\ + + +""")) + + obj = Web.load('https://user.com/post') + self.assertEqual('https://user.com/post', obj.key.id()) + self.assertEqual('https://user.com/post', obj.as1['id']) + + self.assertEqual(NOTE_MF2, obj.mf2) + self.assertNotIn('uid', obj.mf2['properties']) + def test_fetch_user_homepage(self, mock_get, __): mock_get.return_value = ACTOR_HTML_RESP diff --git a/web.py b/web.py index 9350b12..e2eba10 100644 --- a/web.py +++ b/web.py @@ -401,12 +401,17 @@ class Web(User, Protocol): if not entry: error(f'No microformats2 h-entry found in {url}') + # discard uid if set; we use URL as id + props = entry.setdefault('properties', {}) + if 'uid' in props: + logger.info(f'Discarding uid property: {props["uid"]}') + props.pop('uid') + # store final URL in mf2 object, and also default url property to it, # since that's the fallback for AS1/AS2 id if is_homepage: entry.setdefault('rel-urls', {}).update(parsed.get('rel-urls', {})) entry.setdefault('type', ['h-card']) - props = entry.setdefault('properties', {}) if parsed['url']: entry['url'] = parsed['url'] props.setdefault('url', [parsed['url']])