Skip to content

Commit

Permalink
tests for bsky.app hashtag search URLs in ATProto => ActivityPub convert
Browse files Browse the repository at this point in the history
for #1634
  • Loading branch information
snarfed committed Dec 17, 2024
1 parent 4a3249d commit 4ea60ad
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/test_activitypub.py
Original file line number Diff line number Diff line change
Expand Up @@ -2413,6 +2413,7 @@ def test_postprocess_as2_hashtag(self):
'tag': [
{'type': 'Hashtag', 'name': '#bar', 'href': 'bar'},
{'type': 'Hashtag', 'name': '#baz', 'href': '/hashtag/baz'},
{'type': 'Hashtag', 'name': '#biff', 'href': 'http://foo/tag/biff'},
{'type': 'Mention', 'href': 'foo'},
],
'to': [as2.PUBLIC_AUDIENCE],
Expand All @@ -2421,7 +2422,9 @@ def test_postprocess_as2_hashtag(self):
'tag': [
{'name': 'bar', 'href': 'bar'},
{'type': 'Tag', 'name': '#baz'},
# should leave alone
# should leave href alone
{'type': 'Tag', 'name': '#biff', 'href': 'http://foo/tag/biff'},
# should leave alone entirely
{'type': 'Mention', 'href': 'foo'},
],
}))
Expand Down
30 changes: 30 additions & 0 deletions tests/test_integrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,3 +852,33 @@ def test_activitypub_server_actor_flag_to_atproto_report(
'cid': 'alice+sidd',
},
}, data=None, headers=ANY)


def test_atproto_convert_hashtag_to_activitypub_preserves_bsky_app_link(self):
obj = Object(id='at://xyz', bsky={
'$type': 'app.bsky.feed.post',
'text': 'My #original post',
'facets': [{
'$type': 'app.bsky.richtext.facet',
'features': [{
'$type': 'app.bsky.richtext.facet#tag',
'tag': 'original',
}],
'index': {
'byteStart': 3,
'byteEnd': 12,
},
}],
})
self.assert_equals({
'type': 'Note',
'id': 'https://bsky.brid.gy/convert/ap/at://xyz',
'content': '<p>My <a href="https://bsky.app/search?q=%23original">#original</a> post</p>',
'url': 'http://localhost/r/https://bsky.app/profile/xyz',
'tag': [{
'type': 'Hashtag',
'name': '#original',
'href': 'https://bsky.app/search?q=%23original',
}],
}, ActivityPub.convert(obj),
ignore=['@context', 'attributedTo', 'contentMap', 'to'])

0 comments on commit 4ea60ad

Please sign in to comment.