added content-type hint
fixed POST parameters for reports added handling for PATCH requests added check for missing Date header to prevent errors when testing against Puma
This commit is contained in:
pare
973182cda0
commit
91e5388dae
S'han modificat 1 arxius amb 12 adicions i 7 eliminacions
|
@ -643,7 +643,8 @@ class Mastodon:
|
||||||
|
|
||||||
'note' is the user's bio.
|
'note' is the user's bio.
|
||||||
|
|
||||||
'avatar' and 'header' are PNG images encoded in base64.
|
'avatar' and 'header' are images encoded in base64, prepended by a content-type
|
||||||
|
(for example: 'data:image/png;base64,iVBORw0KGgoAAAA[...]')
|
||||||
"""
|
"""
|
||||||
params = self.__generate_params(locals())
|
params = self.__generate_params(locals())
|
||||||
return self.__api_request('PATCH', '/api/v1/accounts/update_credentials', params)
|
return self.__api_request('PATCH', '/api/v1/accounts/update_credentials', params)
|
||||||
|
@ -651,7 +652,7 @@ class Mastodon:
|
||||||
###
|
###
|
||||||
# Writing data: Reports
|
# Writing data: Reports
|
||||||
###
|
###
|
||||||
def report(self, id, toots, comment):
|
def report(self, account_id, status_ids, comment):
|
||||||
"""
|
"""
|
||||||
Report a user to the admin.
|
Report a user to the admin.
|
||||||
|
|
||||||
|
@ -813,6 +814,9 @@ class Mastodon:
|
||||||
if method == 'POST':
|
if method == 'POST':
|
||||||
response_object = requests.post(self.api_base_url + endpoint, data = params, headers = headers, files = files, timeout = self.request_timeout)
|
response_object = requests.post(self.api_base_url + endpoint, data = params, headers = headers, files = files, timeout = self.request_timeout)
|
||||||
|
|
||||||
|
if method == 'PATCH':
|
||||||
|
response_object = requests.patch(self.api_base_url + endpoint, data = params, headers = headers, files = files, timeout = self.request_timeout)
|
||||||
|
|
||||||
if method == 'DELETE':
|
if method == 'DELETE':
|
||||||
response_object = requests.delete(self.api_base_url + endpoint, data = params, headers = headers, files = files, timeout = self.request_timeout)
|
response_object = requests.delete(self.api_base_url + endpoint, data = params, headers = headers, files = files, timeout = self.request_timeout)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -848,11 +852,12 @@ class Mastodon:
|
||||||
self.ratelimit_reset = self.__datetime_to_epoch(ratelimit_reset_datetime)
|
self.ratelimit_reset = self.__datetime_to_epoch(ratelimit_reset_datetime)
|
||||||
|
|
||||||
# Adjust server time to local clock
|
# Adjust server time to local clock
|
||||||
server_time_datetime = dateutil.parser.parse(response_object.headers['Date'])
|
if 'Date' in response_object.headers:
|
||||||
server_time = self.__datetime_to_epoch(server_time_datetime)
|
server_time_datetime = dateutil.parser.parse(response_object.headers['Date'])
|
||||||
server_time_diff = time.time() - server_time
|
server_time = self.__datetime_to_epoch(server_time_datetime)
|
||||||
self.ratelimit_reset += server_time_diff
|
server_time_diff = time.time() - server_time
|
||||||
self.ratelimit_lastcall = time.time()
|
self.ratelimit_reset += server_time_diff
|
||||||
|
self.ratelimit_lastcall = time.time()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise MastodonRatelimitError("Rate limit time calculations failed: %s" % e)
|
raise MastodonRatelimitError("Rate limit time calculations failed: %s" % e)
|
||||||
|
|
||||||
|
|
Loading…
Referencia en una nova incidència