From eb0fa327c4b3b520e243d7b888724512a905347a Mon Sep 17 00:00:00 2001 From: Lorenz Diener Date: Sun, 28 Apr 2019 21:24:31 +0200 Subject: Add reblog visibility --- mastodon/Mastodon.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'mastodon') diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index dd710b7..3fe3d21 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -1370,8 +1370,7 @@ class Mastodon: should be marked as sensitive, which hides it by default on the Mastodon web front-end. - The visibility parameter is a string value and matches the visibility - option on the /api/v1/status POST API endpoint. It accepts any of: + The visibility parameter is a string value and accepts any of: 'direct' - post will be visible only to mentioned users 'private' - post will be visible only to followers 'unlisted' - post will be public but not appear on the public timeline @@ -1514,15 +1513,26 @@ class Mastodon: self.__api_request('DELETE', url) @api_version("1.0.0", "2.0.0", __DICT_VERSION_STATUS) - def status_reblog(self, id): + def status_reblog(self, id, visibility=None): """ - Reblog a status. + Reblog / boost a status. + + The visibility parameter functions the same as in `status_post()`_ and + allows you to reduce the visibility of a reblogged status. Returns a `toot dict`_ with a new status that wraps around the reblogged one. """ + params = self.__generate_params(locals(), ['id']) + valid_visibilities = ['private', 'public', 'unlisted', 'direct'] + if 'visibility' in params: + params['visibility'] = params['visibility'].lower() + if params['visibility'] not in valid_visibilities: + raise ValueError('Invalid visibility value! Acceptable ' + 'values are %s' % valid_visibilities) + id = self.__unpack_id(id) url = '/api/v1/statuses/{0}/reblog'.format(str(id)) - return self.__api_request('POST', url) + return self.__api_request('POST', url, params) @api_version("1.0.0", "2.0.0", __DICT_VERSION_STATUS) def status_unreblog(self, id): -- cgit v1.2.3