aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhalcy <halcy@ARARAGI-KUN>2022-11-22 01:30:43 +0200
committerhalcy <halcy@ARARAGI-KUN>2022-11-22 01:30:43 +0200
commit8865d1123e88b4e8cd5893a7d37c49fffb960853 (patch)
treeed23d92b6e53811b63cb20beb82c3bb0f5eb07cc /mastodon
parentbf96add20c56b23d6c6a7e56de7caf67f0d8d421 (diff)
downloadmastodon.py-8865d1123e88b4e8cd5893a7d37c49fffb960853.tar.gz
Fix some tests, fix a pleroma specific date parsing issue
Diffstat (limited to 'mastodon')
-rw-r--r--mastodon/Mastodon.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py
index a2986cb..99133cf 100644
--- a/mastodon/Mastodon.py
+++ b/mastodon/Mastodon.py
@@ -3538,7 +3538,11 @@ class Mastodon:
3538 else: 3538 else:
3539 json_object[k] = dateutil.parser.parse(v) 3539 json_object[k] = dateutil.parser.parse(v)
3540 except: 3540 except:
3541 raise MastodonAPIError('Encountered invalid date.') 3541 if isinstance(v, str) and len(x.strip()) == 0:
3542 # Pleroma bug workaround: Empty string becomes start of epoch
3543 json_object[k] = datetime.datetime.fromtimestamp(0)
3544 else:
3545 raise MastodonAPIError('Encountered invalid date.')
3542 return json_object 3546 return json_object
3543 3547
3544 @staticmethod 3548 @staticmethod
@@ -3693,10 +3697,8 @@ class Mastodon:
3693 self.ratelimit_reset = int( 3697 self.ratelimit_reset = int(
3694 response_object.headers['X-RateLimit-Reset']) 3698 response_object.headers['X-RateLimit-Reset'])
3695 else: 3699 else:
3696 ratelimit_reset_datetime = dateutil.parser.parse( 3700 ratelimit_reset_datetime = dateutil.parser.parse(response_object.headers['X-RateLimit-Reset'])
3697 response_object.headers['X-RateLimit-Reset']) 3701 self.ratelimit_reset = self.__datetime_to_epoch(ratelimit_reset_datetime)
3698 self.ratelimit_reset = self.__datetime_to_epoch(
3699 ratelimit_reset_datetime)
3700 3702
3701 # Adjust server time to local clock 3703 # Adjust server time to local clock
3702 if 'Date' in response_object.headers: 3704 if 'Date' in response_object.headers:
Powered by cgit v1.2.3 (git 2.41.0)