diff options
author | Lorenz Diener <[email protected]> | 2022-11-05 23:57:17 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2022-11-05 23:57:17 +0200 |
commit | 421aa06b0cee71f33b4c6856ac04572848d0d74b (patch) | |
tree | 1ce5bfd62ae882c2360b665205e1752b6ca0e240 | |
parent | 89a6bd2baca4e651440402773393c19f74ee0993 (diff) | |
parent | 144a4e2b9bdfd371e651f965f21018dc4dd77fd4 (diff) | |
download | mastodon.py-421aa06b0cee71f33b4c6856ac04572848d0d74b.tar.gz |
Merge pull request #248 from fwaggle/fix-gotosocial
Fix gotosocial issues
-rw-r--r-- | mastodon/Mastodon.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index ef428d2..f1a9c5c 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py | |||
@@ -421,20 +421,20 @@ class Mastodon: | |||
421 | if not (self.api_base_url is None or try_base_url == self.api_base_url): | 421 | if not (self.api_base_url is None or try_base_url == self.api_base_url): |
422 | raise MastodonIllegalArgumentError('Mismatch in base URLs between files and/or specified') | 422 | raise MastodonIllegalArgumentError('Mismatch in base URLs between files and/or specified') |
423 | self.api_base_url = try_base_url | 423 | self.api_base_url = try_base_url |
424 | |||
425 | if not version_check_mode in ["created", "changed", "none"]: | ||
426 | raise MastodonIllegalArgumentError("Invalid version check method.") | ||
427 | self.version_check_mode = version_check_mode | ||
424 | 428 | ||
425 | # Versioning | 429 | # Versioning |
426 | if mastodon_version == None: | 430 | if mastodon_version == None and self.version_check_mode != 'none': |
427 | self.retrieve_mastodon_version() | 431 | self.retrieve_mastodon_version() |
428 | else: | 432 | elif self.version_check_mode != 'none': |
429 | try: | 433 | try: |
430 | self.mastodon_major, self.mastodon_minor, self.mastodon_patch = parse_version_string(mastodon_version) | 434 | self.mastodon_major, self.mastodon_minor, self.mastodon_patch = parse_version_string(mastodon_version) |
431 | except: | 435 | except: |
432 | raise MastodonVersionError("Bad version specified") | 436 | raise MastodonVersionError("Bad version specified") |
433 | 437 | ||
434 | if not version_check_mode in ["created", "changed", "none"]: | ||
435 | raise MastodonIllegalArgumentError("Invalid version check method.") | ||
436 | self.version_check_mode = version_check_mode | ||
437 | |||
438 | # Ratelimiting parameter check | 438 | # Ratelimiting parameter check |
439 | if ratelimit_method not in ["throw", "wait", "pace"]: | 439 | if ratelimit_method not in ["throw", "wait", "pace"]: |
440 | raise MastodonIllegalArgumentError("Invalid ratelimit method.") | 440 | raise MastodonIllegalArgumentError("Invalid ratelimit method.") |
@@ -3407,8 +3407,11 @@ class Mastodon: | |||
3407 | self.ratelimit_limit = int(response_object.headers['X-RateLimit-Limit']) | 3407 | self.ratelimit_limit = int(response_object.headers['X-RateLimit-Limit']) |
3408 | 3408 | ||
3409 | try: | 3409 | try: |
3410 | ratelimit_reset_datetime = dateutil.parser.parse(response_object.headers['X-RateLimit-Reset']) | 3410 | if str(int(response_object.headers['X-RateLimit-Reset'])) == response_object.headers['X-RateLimit-Reset']: |
3411 | self.ratelimit_reset = self.__datetime_to_epoch(ratelimit_reset_datetime) | 3411 | self.ratelimit_reset = int(response_object.headers['X-RateLimit-Reset']) |
3412 | else: | ||
3413 | ratelimit_reset_datetime = dateutil.parser.parse(response_object.headers['X-RateLimit-Reset']) | ||
3414 | self.ratelimit_reset = self.__datetime_to_epoch(ratelimit_reset_datetime) | ||
3412 | 3415 | ||
3413 | # Adjust server time to local clock | 3416 | # Adjust server time to local clock |
3414 | if 'Date' in response_object.headers: | 3417 | if 'Date' in response_object.headers: |