activitypub.postprocess_as2: hashtags: use activity id's domain for href

for https://github.com/snarfed/bridgy-fed/issues/1013
pull/1067/head
Ryan Barrett 2024-05-19 16:10:51 -07:00
rodzic ec350e7fa6
commit 9243e18a4f
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
2 zmienionych plików z 3 dodań i 3 usunięć

Wyświetl plik

@ -731,8 +731,8 @@ def postprocess_as2(activity, orig_obj=None, wrap=True):
name = tag.get('name')
if name and tag.get('type', 'Tag') == 'Tag':
tag['type'] = 'Hashtag'
tag.setdefault('href', common.host_url(
f'hashtag/{quote_plus(name.removeprefix("#"))}'))
url_path = f'/hashtag/{quote_plus(name.removeprefix("#"))}'
tag.setdefault('href', urljoin(activity['id'], url_path))
if not name.startswith('#'):
tag['name'] = f'#{name}'

Wyświetl plik

@ -1997,7 +1997,7 @@ class ActivityPubUtilsTest(TestCase):
self.assert_equals({
'tag': [
{'type': 'Hashtag', 'name': '#bar', 'href': 'bar'},
{'type': 'Hashtag', 'name': '#baz', 'href': 'http://localhost/hashtag/baz'},
{'type': 'Hashtag', 'name': '#baz', 'href': '/hashtag/baz'},
{'type': 'Mention', 'href': 'foo'},
],
'to': [as2.PUBLIC_AUDIENCE],