nicer error message on mastodon app creation failure
also log more exceptions to sentry
This commit is contained in:
parent
e07e052d7d
commit
d4d30d0530
40
routes.py
40
routes.py
|
@ -88,6 +88,8 @@ def twitter_login_step1():
|
||||||
**app.config.get_namespace("TWITTER_")
|
**app.config.get_namespace("TWITTER_")
|
||||||
))
|
))
|
||||||
except (TwitterError, URLError):
|
except (TwitterError, URLError):
|
||||||
|
if sentry:
|
||||||
|
sentry.captureException()
|
||||||
return redirect(
|
return redirect(
|
||||||
url_for('index', twitter_login_error='', _anchor='log_in'))
|
url_for('index', twitter_login_error='', _anchor='log_in'))
|
||||||
|
|
||||||
|
@ -112,6 +114,8 @@ def twitter_login_step2():
|
||||||
set_session_cookie(session, resp, app.config.get('HTTPS'))
|
set_session_cookie(session, resp, app.config.get('HTTPS'))
|
||||||
return resp
|
return resp
|
||||||
except (TwitterError, URLError):
|
except (TwitterError, URLError):
|
||||||
|
if sentry:
|
||||||
|
sentry.captureException()
|
||||||
return redirect(
|
return redirect(
|
||||||
url_for('index', twitter_login_error='', _anchor='log_in'))
|
url_for('index', twitter_login_error='', _anchor='log_in'))
|
||||||
|
|
||||||
|
@ -144,6 +148,8 @@ def upload_tweet_archive():
|
||||||
|
|
||||||
return redirect(url_for('index', _anchor='recent_archives'))
|
return redirect(url_for('index', _anchor='recent_archives'))
|
||||||
except (BadZipFile, TweetArchiveEmptyException):
|
except (BadZipFile, TweetArchiveEmptyException):
|
||||||
|
if sentry:
|
||||||
|
sentry.captureException()
|
||||||
return redirect(
|
return redirect(
|
||||||
url_for('index', tweet_archive_failed='',
|
url_for('index', tweet_archive_failed='',
|
||||||
_anchor='tweet_archive_import'))
|
_anchor='tweet_archive_import'))
|
||||||
|
@ -160,6 +166,8 @@ def settings():
|
||||||
setattr(viewer, attr, request.form[attr])
|
setattr(viewer, attr, request.form[attr])
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
if sentry:
|
||||||
|
sentry.captureException()
|
||||||
return 400
|
return 400
|
||||||
|
|
||||||
return redirect(url_for('index', settings_saved=''))
|
return redirect(url_for('index', settings_saved=''))
|
||||||
|
@ -267,17 +275,17 @@ def api_viewer_timers():
|
||||||
|
|
||||||
@app.route('/login/mastodon', methods=('GET', 'POST'))
|
@app.route('/login/mastodon', methods=('GET', 'POST'))
|
||||||
def mastodon_login_step1(instance=None):
|
def mastodon_login_step1(instance=None):
|
||||||
instances = (
|
|
||||||
MastodonInstance
|
|
||||||
.query.filter(MastodonInstance.popularity > 1)
|
|
||||||
.order_by(db.desc(MastodonInstance.popularity),
|
|
||||||
MastodonInstance.instance)
|
|
||||||
.limit(30))
|
|
||||||
|
|
||||||
instance_url = (request.args.get('instance_url', None)
|
instance_url = (request.args.get('instance_url', None)
|
||||||
or request.form.get('instance_url', None))
|
or request.form.get('instance_url', None))
|
||||||
|
|
||||||
if not instance_url:
|
if not instance_url:
|
||||||
|
instances = (
|
||||||
|
MastodonInstance
|
||||||
|
.query.filter(MastodonInstance.popularity > 1)
|
||||||
|
.order_by(db.desc(MastodonInstance.popularity),
|
||||||
|
MastodonInstance.instance)
|
||||||
|
.limit(30))
|
||||||
return render_template(
|
return render_template(
|
||||||
'mastodon_login.html', instances=instances,
|
'mastodon_login.html', instances=instances,
|
||||||
address_error=request.method == 'POST',
|
address_error=request.method == 'POST',
|
||||||
|
@ -289,15 +297,21 @@ def mastodon_login_step1(instance=None):
|
||||||
callback = url_for('mastodon_login_step2',
|
callback = url_for('mastodon_login_step2',
|
||||||
instance=instance_url, _external=True)
|
instance=instance_url, _external=True)
|
||||||
|
|
||||||
app = lib.mastodon.get_or_create_app(
|
try:
|
||||||
instance_url,
|
app = lib.mastodon.get_or_create_app(
|
||||||
callback,
|
instance_url,
|
||||||
url_for('index', _external=True))
|
callback,
|
||||||
db.session.merge(app)
|
url_for('index', _external=True))
|
||||||
|
db.session.merge(app)
|
||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
return redirect(lib.mastodon.login_url(app, callback))
|
return redirect(lib.mastodon.login_url(app, callback))
|
||||||
|
|
||||||
|
except Exception:
|
||||||
|
if sentry:
|
||||||
|
sentry.captureException()
|
||||||
|
return redirect(url_for('mastodon_login_step1', error=True))
|
||||||
|
|
||||||
|
|
||||||
@app.route('/login/mastodon/callback/<instance>')
|
@app.route('/login/mastodon/callback/<instance>')
|
||||||
|
|
Loading…
Reference in New Issue