diff --git a/files/routes/comments.py b/files/routes/comments.py index 61db7be8d..b44b7cd03 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -1,3 +1,6 @@ +import traceback +import sys + from files.helpers.wrappers import * from files.helpers.filters import * from files.helpers.alerts import * @@ -5,7 +8,7 @@ from files.helpers.images import * from files.helpers.session import * from files.classes import * from files.routes.front import comment_idlist -from pusher_push_notifications import PushNotifications +from pusher_push_notifications import PushNotifications, PusherAuthError from flask import * from files.__main__ import app, limiter @@ -530,18 +533,23 @@ def api_comment(v): except: g.db.rollback() if parent.author.id != v.id: - beams_client.publish_to_interests( - interests=[str(parent.author.id)], - publish_body={ - 'web': { - 'notification': { - 'title': f'New reply by @{v.username}', - 'body': c.body, - 'deep_link': f'https://{site}{c.permalink}?context=5#context', + try: + beams_client.publish_to_interests( + interests=[str(parent.author.id)], + publish_body={ + 'web': { + 'notification': { + 'title': f'New reply by @{v.username}', + 'body': c.body, + 'deep_link': f'https://{site}{c.permalink}?context=5#context', + }, + }, }, - }, - }, - ) + ) + except PusherAuthError as e: + sys.stderr.write(traceback.format_exc()) + sys.stderr.flush() + @@ -866,4 +874,4 @@ def unsave_comment(cid, v): g.db.delete(save) - return "", 204 \ No newline at end of file + return "", 204 diff --git a/files/routes/users.py b/files/routes/users.py index c769554c8..2790ef440 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -1,6 +1,8 @@ import qrcode import io import time +import traceback +import sys from files.classes.user import ViewerRelationship from files.helpers.alerts import * @@ -9,7 +11,7 @@ from files.helpers.markdown import * from files.mail import * from flask import * from files.__main__ import app, limiter -from pusher_push_notifications import PushNotifications +from pusher_push_notifications import PushNotifications, PusherAuthError site = environ.get("DOMAIN").strip() @@ -142,18 +144,24 @@ def message2(v, username): if existing: return redirect('/notifications?all=true') send_pm(v.id, user, message) - beams_client.publish_to_interests( - interests=[str(user.id)], - publish_body={ - 'web': { - 'notification': { - 'title': f'New message from @{v.username}', - 'body': message, - 'deep_link': f'https://{site}/notifications', + + try: + beams_client.publish_to_interests( + interests=[str(user.id)], + publish_body={ + 'web': { + 'notification': { + 'title': f'New message from @{v.username}', + 'body': message, + 'deep_link': f'https://{site}/notifications', + }, }, }, - }, - ) + ) + except PusherAuthError as e: + sys.stderr.write(traceback.format_exc()) + sys.stderr.flush() + return redirect('/notifications?all=true') @app.get("/2faqr/") @@ -541,4 +549,4 @@ def saved_comments(v, username): listing=listing, page=page, next_exists=next_exists, - standalone=True) \ No newline at end of file + standalone=True) diff --git a/seed-db.sql b/seed-db.sql index 55f3eca56..fc88b293a 100644 --- a/seed-db.sql +++ b/seed-db.sql @@ -1 +1 @@ -INSERT INTO public.badge_defs VALUES (6, 'Beta User', 'Joined during open beta', 'beta.png', 4, 3, NULL); \ No newline at end of file +INSERT INTO public.badge_defs VALUES (6, 'Beta User', 'Joined during open beta', 'beta.png', 4, 3, NULL);