fix exception in log_in, by accepting json dates as timestamps
when requesting a bearer token, mastodon (more specifically doorkeeper) returns an object with a created_at attribute which is a plain timestamp unlike in most of mastodon's api: { "access_token": "hunter2", "token_type": "bearer", "scope": "read write", "created_at": 1504824250, }
This commit is contained in:
pare
7ded08fd84
commit
92dd24450d
S'han modificat 1 arxius amb 4 adicions i 1 eliminacions
|
@ -973,7 +973,10 @@ class Mastodon:
|
||||||
for k, v in json_object.items():
|
for k, v in json_object.items():
|
||||||
if k in known_date_fields:
|
if k in known_date_fields:
|
||||||
try:
|
try:
|
||||||
json_object[k] = dateutil.parser.parse(v)
|
if isinstance(v, int):
|
||||||
|
json_object[k] = datetime.datetime.fromtimestamp(v, pytz.utc)
|
||||||
|
else:
|
||||||
|
json_object[k] = dateutil.parser.parse(v)
|
||||||
except:
|
except:
|
||||||
raise MastodonAPIError('Encountered invalid date.')
|
raise MastodonAPIError('Encountered invalid date.')
|
||||||
return json_object
|
return json_object
|
||||||
|
|
Loading…
Referencia en una nova incidència