From 5cf2359749d77bd9c0619db1339aa002b59d00a2 Mon Sep 17 00:00:00 2001 From: Philipp Herz Date: Mon, 18 Dec 2023 16:39:11 +0100 Subject: [PATCH] Use enum value for 'listing_type' in api calls 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. --- lemmylib/lib.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lemmylib/lib.py b/lemmylib/lib.py index 505121f..a4f2b61 100644 --- a/lemmylib/lib.py +++ b/lemmylib/lib.py @@ -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, @@ -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,