mirror of
https://github.com/codl/forget
synced 2025-01-20 19:11:15 +01:00
report revoked or otherwise erroneous creds to sentry
This commit is contained in:
parent
2c02dd63bc
commit
9bc92fc1f0
@ -2,7 +2,7 @@ from mastodon import Mastodon
|
||||
from mastodon.Mastodon import MastodonAPIError
|
||||
from model import MastodonApp, Account, OAuthToken, Post
|
||||
from requests import head
|
||||
from app import db
|
||||
from app import db, sentry
|
||||
from math import inf
|
||||
import iso8601
|
||||
|
||||
@ -83,6 +83,15 @@ def get_api_for_acc(account):
|
||||
# so we have to do this:
|
||||
tl = api.timeline()
|
||||
if 'error' in tl:
|
||||
if sentry:
|
||||
sentry.capture(
|
||||
'lib.mastodon.creds_error',
|
||||
stack=True,
|
||||
data=dict(
|
||||
locals=locals(),
|
||||
account=account,
|
||||
)
|
||||
)
|
||||
db.session.delete(token)
|
||||
continue
|
||||
return api
|
||||
|
@ -1,7 +1,7 @@
|
||||
from twitter import Twitter, OAuth, TwitterHTTPError
|
||||
from werkzeug.urls import url_decode
|
||||
from model import OAuthToken, Account, Post, TwitterArchive
|
||||
from app import db, app
|
||||
from app import db, app, sentry
|
||||
from math import inf
|
||||
from datetime import datetime
|
||||
import locale
|
||||
@ -79,6 +79,16 @@ def get_twitter_for_acc(account):
|
||||
except TwitterHTTPError as e:
|
||||
if e.e.code == 401:
|
||||
# token revoked
|
||||
|
||||
if sentry:
|
||||
sentry.capture(
|
||||
'lib.twitter.creds_error',
|
||||
stack=True,
|
||||
data=dict(
|
||||
locals=locals(),
|
||||
account=account,
|
||||
)
|
||||
)
|
||||
db.session.delete(token)
|
||||
db.session.commit()
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user