aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenz Diener <[email protected]>2016-11-26 00:03:19 +0100
committerLorenz Diener <[email protected]>2016-11-26 00:03:19 +0100
commit6f923ad1f9ef596a1de61452cc50148875666c09 (patch)
treed382e801ea35fde5a4d7e953e91a5f80f664438e /mastodon
parent6a5ba9bab65a47ae65b3443e52f8deabc07cf22f (diff)
downloadmastodon.py-6f923ad1f9ef596a1de61452cc50148875666c09.tar.gz
media_ids can not just be dicts, for extra lazyness
Diffstat (limited to 'mastodon')
-rw-r--r--mastodon/Mastodon.py26
1 files changed, 24 insertions, 2 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py
index c437618..349bc03 100644
--- a/mastodon/Mastodon.py
+++ b/mastodon/Mastodon.py
@@ -312,11 +312,28 @@ class Mastodon:
312 def status_post(self, status, in_reply_to_id = None, media_ids = None): 312 def status_post(self, status, in_reply_to_id = None, media_ids = None):
313 """ 313 """
314 Post a status. Can optionally be in reply to another status and contain 314 Post a status. Can optionally be in reply to another status and contain
315 up to four pieces of media (Uploaded via media_post()). 315 up to four pieces of media (Uploaded via media_post()). media_ids can
316 also be the media dicts returned by media_post - they are unpacked
317 automatically.
316 318
317 Returns a toot dict with the new status. 319 Returns a toot dict with the new status.
318 """ 320 """
319 params = self.__generate_params(locals()) 321 params_initial = locals()
322
323 if media_ids != None:
324 try:
325 media_ids_proper = []
326 for media_id in media_ids:
327 if isinstance(media_id, dict):
328 media_ids_proper.append(media_id["id"])
329 else:
330 media_ids_proper.append(media_id)
331 except:
332 raise MastodonIllegalArgumentError("Invalid media dict.")
333
334 params_initial["media_ids"] = media_ids_proper
335
336 params = self.__generate_params(params_initial)
320 return self.__api_request('POST', '/api/v1/statuses', params) 337 return self.__api_request('POST', '/api/v1/statuses', params)
321 338
322 def toot(self, status): 339 def toot(self, status):
@@ -558,6 +575,11 @@ class Mastodon:
558 def __generate_params(self, params, exclude = []): 575 def __generate_params(self, params, exclude = []):
559 """ 576 """
560 Internal named-parameters-to-dict helper. 577 Internal named-parameters-to-dict helper.
578
579 Note for developers: If called with locals() as params,
580 as is the usual practice in this code, the __generate_params call
581 (or at least the locals() call) should generally be the first thing
582 in your function.
561 """ 583 """
562 params = dict(params) 584 params = dict(params)
563 585
Powered by cgit v1.2.3 (git 2.41.0)