mirror of
https://github.com/codl/forget
synced 2025-01-20 19:11:15 +01:00
fix: mastodon.py now throws on revoked tokens
This commit is contained in:
parent
a787f26e9a
commit
cce01b3b51
@ -78,23 +78,24 @@ def get_api_for_acc(account):
|
||||
access_token=token.token,
|
||||
ratelimit_method='throw',
|
||||
)
|
||||
|
||||
try:
|
||||
# api.verify_credentials()
|
||||
# doesnt error even if the token is revoked lol
|
||||
# https://github.com/tootsuite/mastodon/issues/4637
|
||||
# so we have to do this:
|
||||
tl = api.timeline()
|
||||
if 'error' in tl:
|
||||
return api
|
||||
except MastodonAPIError as e:
|
||||
if 'token' in str(e):
|
||||
if sentry:
|
||||
sentry.captureMessage('Mastodon auth revoked or incorrect',
|
||||
extra=locals())
|
||||
sentry.captureMessage(
|
||||
'Mastodon auth revoked or incorrect',
|
||||
extra=locals())
|
||||
db.session.delete(token)
|
||||
db.session.commit()
|
||||
continue
|
||||
return api
|
||||
except (MastodonAPIError,
|
||||
MastodonNetworkError,
|
||||
raise TemporaryError(e)
|
||||
except (MastodonNetworkError,
|
||||
MastodonRatelimitError) as e:
|
||||
raise TemporaryError(e)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user