From da9bdb4dbb8dc9680dedd4331c336ff16ef42b30 Mon Sep 17 00:00:00 2001 From: Jason McBrayer Date: Thu, 24 Jan 2019 10:06:33 -0500 Subject: [PATCH] Add 'content_type' parameter to status_post() for use with Pleroma This parameter lets you specify the source content type of your post for Pleroma servers, and accepts 'text/plain', 'text/markdown', and 'text/html'. It defaults to None, but if set on a request to a Mastodon server, it will be safely ignored. --- mastodon/Mastodon.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index fc585ba..f78d303 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -1144,7 +1144,7 @@ class Mastodon: @api_version("1.0.0", "2.4.3", __DICT_VERSION_STATUS) def status_post(self, status, in_reply_to_id=None, media_ids=None, sensitive=False, visibility=None, spoiler_text=None, - language=None, idempotency_key=None): + language=None, idempotency_key=None, content_type=None): """ Post a status. Can optionally be in reply to another status and contain media. @@ -1182,6 +1182,11 @@ class Mastodon: if you call it with the same `idempotency_key`, only one status will be created. + Specify 'content_type' to set the content type of your post on Pleroma. + It accepts 'text/plain' (default), 'text/markdown', and 'text/html'. + This parameter is not supported on Mastodon servers, but will be + safely ignored if set. + Returns a `toot dict`_ with the new status. """ if in_reply_to_id != None: @@ -1225,6 +1230,9 @@ class Mastodon: params_initial["media_ids"] = media_ids_proper + if params_initial['content_type'] == None: + del params_initial['content_type'] + params = self.__generate_params(params_initial, ['idempotency_key']) return self.__api_request('POST', '/api/v1/statuses', params, headers = headers)