Skip to content

Commit

Permalink
Use enum value for 'listing_type' in api calls
Browse files Browse the repository at this point in the history
The bug in the API calls for listing comments and posts within the 'lemmylib' library has been fixed. The 'type_' parameter key was previously incorrectly expecting the entire 'listing_type' enum instance, but it now correctly expects the 'value' attribute of the 'listing_type' enum instance.
  • Loading branch information
Pdzly committed Dec 18, 2023
1 parent 86e2d0a commit 5cf2359
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions lemmylib/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,15 @@ def list_comments(self, page: int = 1, post_id: int | None = None, sort: LemmyPo
if post_id is None and community_id is None and community_name is None and user_id is None and user_name is None:
raise Exception("LemmyLib: Either post_id, community_id, community_name, user_id or user_name must be set")

return self.call_api(LemmyApiMethod.GET, f'comments', params={'page': page, 'post_id': post_id, 'sort': sort,
'type_': listing_type.value,
'parent_id': parent_id,
'community_id': community_id,
'community_name': community_name,
'user_id': user_id,
'user_name': user_name,
'saved_only': saved_only})
return self.call_api(LemmyApiMethod.GET, f'comments',
params={'page': page, 'post_id': post_id, 'sort': sort.value,
'type_': listing_type.value,
'parent_id': parent_id,
'community_id': community_id,
'community_name': community_name,
'user_id': user_id,
'user_name': user_name,
'saved_only': saved_only})

def list_posts(self,
page: int | None = None, page_cursor: int | None = None, sort: LemmyPostSort = None,
Expand All @@ -219,7 +220,7 @@ def list_posts(self,
self._logger.debug("LemmyLib list_posts")

return self.call_api(LemmyApiMethod.GET, f'posts',
params={'page_cursor': page_cursor, 'sort': sort, 'type_': listing_type.value,
params={'page_cursor': page_cursor, 'sort': sort.value, 'type_': listing_type.value,
'community_id': community_id,
'page': page,
'community_name': community_name,
Expand Down

0 comments on commit 5cf2359

Please sign in to comment.