aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenz Diener <[email protected]>2019-10-12 19:35:22 +0200
committerLorenz Diener <[email protected]>2019-10-12 19:35:22 +0200
commit86d06ea48c5742cc44e749023155a0d176cef4cc (patch)
tree7f1c1d312cb7ed0ac3cf95b4462676a26788a6ac /mastodon
parent5e776519ef53f165f6c099e8312e0510cef9fc08 (diff)
downloadmastodon.py-86d06ea48c5742cc44e749023155a0d176cef4cc.tar.gz
Add "feature set" support and "quote_id" support for fedibird.
Diffstat (limited to 'mastodon')
-rw-r--r--mastodon/Mastodon.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py
index dfac4d0..70de3dd 100644
--- a/mastodon/Mastodon.py
+++ b/mastodon/Mastodon.py
@@ -280,7 +280,7 @@ class Mastodon:
280 api_base_url=None, debug_requests=False, 280 api_base_url=None, debug_requests=False,
281 ratelimit_method="wait", ratelimit_pacefactor=1.1, 281 ratelimit_method="wait", ratelimit_pacefactor=1.1,
282 request_timeout=__DEFAULT_TIMEOUT, mastodon_version=None, 282 request_timeout=__DEFAULT_TIMEOUT, mastodon_version=None,
283 version_check_mode = "created", session=None): 283 version_check_mode = "created", session=None, feature_set="mainline"):
284 """ 284 """
285 Create a new API wrapper instance based on the given `client_secret` and `client_id`. If you 285 Create a new API wrapper instance based on the given `client_secret` and `client_id`. If you
286 give a `client_id` and it is not a file, you must also give a secret. If you specify an 286 give a `client_id` and it is not a file, you must also give a secret. If you specify an
@@ -321,6 +321,10 @@ class Mastodon:
321 to have an endpoint. If it is set to "changed", it will throw an error if the endpoints behaviour has 321 to have an endpoint. If it is set to "changed", it will throw an error if the endpoints behaviour has
322 changed after the version of Mastodon that is connected has been released. If it is set to "none", 322 changed after the version of Mastodon that is connected has been released. If it is set to "none",
323 version checking is disabled. 323 version checking is disabled.
324
325 `feature_set` can be used to enable behaviour specific to non-mainline Mastodon API implementations.
326 Details are documented in the functions that provide such functionality. Currently supported feature
327 sets are `mainline` and `fedibird`.
324 """ 328 """
325 self.api_base_url = None 329 self.api_base_url = None
326 if not api_base_url is None: 330 if not api_base_url is None:
@@ -349,6 +353,10 @@ class Mastodon:
349 else: 353 else:
350 self.session = requests.Session() 354 self.session = requests.Session()
351 355
356 self.feature_set = feature_set
357 if not self.feature_set in ["mainline", "fedibird"]:
358 raise MastodonIllegalArgumentError('Requested invalid feature set')
359
352 # Versioning 360 # Versioning
353 if mastodon_version == None: 361 if mastodon_version == None:
354 self.retrieve_mastodon_version() 362 self.retrieve_mastodon_version()
@@ -1487,7 +1495,7 @@ class Mastodon:
1487 def status_post(self, status, in_reply_to_id=None, media_ids=None, 1495 def status_post(self, status, in_reply_to_id=None, media_ids=None,
1488 sensitive=False, visibility=None, spoiler_text=None, 1496 sensitive=False, visibility=None, spoiler_text=None,
1489 language=None, idempotency_key=None, content_type=None, 1497 language=None, idempotency_key=None, content_type=None,
1490 scheduled_at=None, poll=None): 1498 scheduled_at=None, poll=None, quote_id=None):
1491 """ 1499 """
1492 Post a status. Can optionally be in reply to another status and contain 1500 Post a status. Can optionally be in reply to another status and contain
1493 media. 1501 media.
@@ -1538,8 +1546,16 @@ class Mastodon:
1538 This parameter is not supported on Mastodon servers, but will be 1546 This parameter is not supported on Mastodon servers, but will be
1539 safely ignored if set. 1547 safely ignored if set.
1540 1548
1549 **Specific to `fedibird` feature set:**: The `quote_id` parameter is
1550 a non-standard extension that specifies the id of a quoted status.
1551
1541 Returns a `toot dict`_ with the new status. 1552 Returns a `toot dict`_ with the new status.
1542 """ 1553 """
1554 if quote_id != None:
1555 if self.feature_set != "fedibird":
1556 raise MastodonIllegalArgumentError('quote_id is only available with feature set fedibird')
1557 quote_id = self.__unpack_id(quote_id)
1558
1543 if in_reply_to_id != None: 1559 if in_reply_to_id != None:
1544 in_reply_to_id = self.__unpack_id(in_reply_to_id) 1560 in_reply_to_id = self.__unpack_id(in_reply_to_id)
1545 1561
Powered by cgit v1.2.3 (git 2.41.0)