Skip to content

Commit

Permalink
Address nits
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelOtter committed Jul 26, 2023
1 parent 2565f42 commit e393c30
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions granary/bluesky.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ def to_as1(obj, type=None):
reason = obj.get('reason')
if reason and reason.get('$type') == 'app.bsky.feed.defs#reasonRepost':
ret = {
'id': obj.get('post').get('viewer').get('repost'),
'id': obj.get('post', {}).get('viewer', {}).get('repost'),
'objectType': 'activity',
'verb': 'share',
'object': ret,
Expand Down Expand Up @@ -862,7 +862,7 @@ def _make_like_or_share(self, post, actor, verb):
Returns: dict, AS1 like activity
"""
assert verb in ('like', 'share')
label = 'favorited' if verb == 'like' else 'reblogged'
label = 'liked' if verb == 'like' else 'reposted'
url = at_uri_to_web_url(post.get('uri'), post.get('author').get('handle'))
actor_id = actor.get('did')
author = to_as1(actor, 'app.bsky.actor.defs#profileView')
Expand All @@ -884,19 +884,20 @@ def _get_replies(self, uri):
Args:
uri: string, post uri
Returns: array, Bluesky app.bsky.feed.defs#threadViewPost
Returns: list, Bluesky app.bsky.feed.defs#threadViewPost
"""
ret = []
resp = self.client.app.bsky.feed.getPostThread({}, uri=uri)
thread = resp.get('thread')
if thread:
ret = self._recurse_replies(thread)
return sorted(ret, key = lambda thread: thread.get('post').get('record').get('createdAt'))
return sorted(ret, key = lambda thread: thread.get('post', {}).get('record', {}).get('createdAt'))

# TODO this ought to take a depth limit.
def _recurse_replies(self, thread):
"""
Recurses through a Bluesky app.bsky.feed.defs#threadViewPost
and returns its replies as an array.
and returns its replies as a list.
Args:
thread: dict, Bluesky app.bsky.feed.defs#threadViewPost
Expand Down

0 comments on commit e393c30

Please sign in to comment.