Skip to content

Commit

Permalink
Add depth=1 to get_comment, add test
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelOtter committed Oct 21, 2023
1 parent 5725ee0 commit 64f5a89
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion granary/bluesky.py
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,7 @@ def get_comment(self, comment_id, **kwargs):
Raises:
:class:`ValueError`: if comment_id is invalid
"""
post_thread = self.client.app.bsky.feed.getPostThread({}, uri=comment_id)
post_thread = self.client.app.bsky.feed.getPostThread({}, uri=comment_id, depth=1)
obj = to_as1(post_thread.get('thread'), 'app.bsky.feed.defs#threadViewPost')
return obj

Expand Down
25 changes: 25 additions & 0 deletions granary/tests/test_bluesky.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
'description': 'hi there',
}

POST_OBJ_AS = {

}

POST_AS = {
'objectType': 'activity',
'id': 'at://did/app.bsky.feed.post/tid',
Expand Down Expand Up @@ -830,3 +834,24 @@ def test_get_activities_self_user_id(self, mock_get):
'User-Agent': util.user_agent,
},
)

@patch('requests.get')
def test_get_comment(self, mock_get):
mock_get.return_value = requests_response({
'$type': 'app.bsky.feed.defs#threadViewPost',
'thread': THREAD_BSKY,
'replies': [REPLY_BSKY],
})

self.assert_equals(POST_AUTHOR_PROFILE_AS['object'],
self.bs.get_comment(comment_id='at://id'))
mock_get.assert_called_once_with(
'https://bsky.social/xrpc/app.bsky.feed.getPostThread?uri=at%3A%2F%2Fid&depth=1',
json=None,
headers={
'Authorization': 'Bearer towkin',
'Content-Type': 'application/json',
'User-Agent': util.user_agent,
},
)

0 comments on commit 64f5a89

Please sign in to comment.