Skip to content

Commit

Permalink
[mastodon] Omit empty limit param in search API call, for Pleroma
Browse files Browse the repository at this point in the history
  • Loading branch information
snarfed committed Sep 30, 2020
1 parent af53199 commit d05ad0f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ Changelog
* Bug fix: URL-encode list names in API calls.
* Mastodon:
* Bug fix for alt text with image attachments ([bridgy#975](https://github.com/snarfed/bridgy/issues/975)).
* Omit empty `limit` param [for compatibility with Pleroma](https://git.pleroma.social/pleroma/pleroma/-/issues/2198) ([bridgy#977](https://github.com/snarfed/bridgy/issues/977)).

### 3.0 - 2020-04-08

Expand Down
2 changes: 1 addition & 1 deletion granary/mastodon.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def get_activities_response(self, user_id=None, group_id=None, app_id=None,
'q': search_query,
'resolve': True,
'offset': start_index,
'limit': count if count else '',
**params,
}).get('statuses', [])
else: # eg group_id SELF
statuses = self._get(API_ACCOUNT_STATUSES % user_id, params=params)
Expand Down
14 changes: 12 additions & 2 deletions granary/tests/test_mastodon.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,17 +420,27 @@ def test_get_activities_self_default_user(self):
self.mox.ReplayAll()
self.assert_equals([ACTIVITY], self.mastodon.get_activities(group_id=source.SELF))

def test_get_activities_search(self):
def test_get_activities_search_without_count(self):
self.expect_get(API_SEARCH, params={
'q': 'indieweb',
'resolve': True,
'offset': 0,
'limit': '',
}, response={'statuses': [STATUS, MEDIA_STATUS]})
self.mox.ReplayAll()
self.assert_equals([ACTIVITY, MEDIA_ACTIVITY], self.mastodon.get_activities(
group_id=source.SEARCH, search_query='indieweb'))

def test_get_activities_search_with_count(self):
self.expect_get(API_SEARCH, params={
'q': 'indieweb',
'resolve': True,
'offset': 0,
'limit': 123,
}, response={'statuses': [STATUS, MEDIA_STATUS]})
self.mox.ReplayAll()
self.assert_equals([ACTIVITY, MEDIA_ACTIVITY], self.mastodon.get_activities(
group_id=source.SEARCH, search_query='indieweb', count=123))

def test_get_activities_search_no_query(self):
with self.assertRaises(ValueError):
self.mastodon.get_activities(group_id=source.SEARCH, search_query=None)
Expand Down

0 comments on commit d05ad0f

Please sign in to comment.