fix seed-db, make comments and private messages work without pusher

by catching and printing pusher auth error exception
remotes/1693045480750635534/spooky-22
atrc445 2021-08-03 19:55:02 +02:00
parent 31cdc1f0da
commit 9d822af154
3 changed files with 68 additions and 26 deletions

View File

@ -1,3 +1,6 @@
import traceback
import sys
from drama.helpers.wrappers import *
from drama.helpers.filters import *
from drama.helpers.alerts import *
@ -5,7 +8,7 @@ from drama.helpers.images import *
from drama.helpers.session import *
from drama.classes import *
from drama.routes.front import comment_idlist
from pusher_push_notifications import PushNotifications
from pusher_push_notifications import PushNotifications, PusherAuthError
from flask import *
from drama.__main__ import app, limiter
@ -522,18 +525,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:
traceback.print_tb(e.__traceback__)
sys.stderr.flush()
@ -858,4 +866,4 @@ def unsave_comment(cid, v):
g.db.delete(save)
return "", 204
return "", 204

View File

@ -1,6 +1,8 @@
import qrcode
import io
import time
import traceback
import sys
from drama.classes.user import ViewerRelationship
from drama.helpers.alerts import *
@ -9,7 +11,7 @@ from drama.helpers.markdown import *
from drama.mail import *
from flask import *
from drama.__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:
traceback.print_tb(e.__traceback__)
sys.stderr.flush()
return redirect('/notifications?all=true')
@app.get("/2faqr/<secret>")
@ -541,4 +549,4 @@ def saved_comments(v, username):
listing=listing,
page=page,
next_exists=next_exists,
standalone=True)
standalone=True)

View File

@ -1 +1,27 @@
INSERT INTO public.badge_defs VALUES (6, 'Beta User', 'Joined during open beta', 'beta.png', 4, 3, NULL);
INSERT INTO public.users
(id, username, passhash,
created_utc, admin_level, over_18, is_activated, is_banned,
is_private, login_nonce, dramacoins, original_username, bio,
defaultsorting, defaultsortingcomments, namecolor, titlecolor, theme, themecolor)
VALUES
-- admin:admin
(1, 'admin', 'pbkdf2:sha256:150000$z6kifBOp$1ee4ab0b1d565d541715d128d4d00dee2800f157ac3865546efed28bbb726dac',
0, 6, false, true, 0,
false, 0, 0, 'admin', '',
'hot', 'top', 'ff66ac', 'ff66ac', 'dark', 'ff66ac');
INSERT INTO public.users
(id, username, passhash,
created_utc, admin_level, over_18, is_activated, is_banned,
is_private, login_nonce, dramacoins, original_username, bio,
defaultsorting, defaultsortingcomments, namecolor, titlecolor, theme, themecolor)
VALUES
-- user:user
(2, 'user', 'pbkdf2:sha256:150000$gB7i3Vsj$7e78baba3b3eb8030bef8850f7016369221152488b27b50f48432bd7713a7e31',
0, 0, false, true, 0,
false, 0, 0, 'user', '',
'hot', 'top', 'ff66ac', 'ff66ac', 'dark', 'ff66ac');
INSERT INTO public.badge_defs VALUES (6, 'Beta User', 'Joined Drama during open beta', 'beta.png', 4, 3, NULL);
SELECT pg_catalog.setval('public.users_id_seq', 2, true);