kopia lustrzana https://github.com/halcy/Mastodon.py
Handle UNIX Epoch times in X-RateLimit-Reset
Instead of returning an ISO8601 timestamp, gotosocial returns an integer UNIX Epoch for the X-RateLimit-Reset header. As `dateutil.parser.parse` doesn't handle these, I do a naive check to see if the header is an integer and don't parse it if so. Fixes #246pull/248/head
rodzic
89a6bd2bac
commit
b69e998ceb
|
@ -3407,8 +3407,11 @@ class Mastodon:
|
|||
self.ratelimit_limit = int(response_object.headers['X-RateLimit-Limit'])
|
||||
|
||||
try:
|
||||
ratelimit_reset_datetime = dateutil.parser.parse(response_object.headers['X-RateLimit-Reset'])
|
||||
self.ratelimit_reset = self.__datetime_to_epoch(ratelimit_reset_datetime)
|
||||
if str(int(response_object.headers['X-RateLimit-Reset'])) == response_object.headers['X-RateLimit-Reset']:
|
||||
self.ratelimit_reset = int(response_object.headers['X-RateLimit-Reset'])
|
||||
else:
|
||||
ratelimit_reset_datetime = dateutil.parser.parse(response_object.headers['X-RateLimit-Reset'])
|
||||
self.ratelimit_reset = self.__datetime_to_epoch(ratelimit_reset_datetime)
|
||||
|
||||
# Adjust server time to local clock
|
||||
if 'Date' in response_object.headers:
|
||||
|
|
Ładowanie…
Reference in New Issue