fix 500 error
parent
d2bda15383
commit
22051152de
|
@ -143,16 +143,18 @@ def NOTIFY_USERS(text, v):
|
|||
return notify_users - bots - {v.id, 0}
|
||||
|
||||
|
||||
def push_notif(uids, title, body, url):
|
||||
def push_notif(uids, title, body, url_or_comment):
|
||||
if VAPID_PUBLIC_KEY == DEFAULT_CONFIG_VALUE:
|
||||
return
|
||||
|
||||
if isinstance(url, tuple):
|
||||
cid, posting_to_submission = url
|
||||
if posting_to_submission:
|
||||
url = f'{SITE_FULL}/comment/{cid}?read=true#context'
|
||||
if isinstance(url_or_comment, Comment):
|
||||
c = url_or_comment
|
||||
if c.wall_user_id:
|
||||
url = f'{SITE_FULL}/@{c.wall_user.username}/wall/comment/{c.id}?read=true#context'
|
||||
else:
|
||||
url = f'{SITE_FULL}/@{c.wall_user.username}/wall/comment/{cid}?read=true#context'
|
||||
url = f'{SITE_FULL}/comment/{c.id}?read=true#context'
|
||||
else:
|
||||
url = url_or_comment
|
||||
|
||||
if len(body) > PUSH_NOTIF_LIMIT:
|
||||
body = body[:PUSH_NOTIF_LIMIT] + "..."
|
||||
|
|
|
@ -227,7 +227,7 @@ def execute_blackjack(v, target, body, type):
|
|||
n = Notification(comment_id=target.id, user_id=id)
|
||||
g.db.add(n)
|
||||
|
||||
push_notif(notified_ids, f'Blackjack by @{v.username}', target.body, (target.id,bool(target.wall_user_id)))
|
||||
push_notif(notified_ids, f'Blackjack by @{v.username}', target.body, target)
|
||||
|
||||
extra_info = None
|
||||
|
||||
|
|
|
@ -305,14 +305,14 @@ def comment(v:User):
|
|||
if not v.shadowbanned:
|
||||
notify_users = NOTIFY_USERS(body, v)
|
||||
|
||||
push_notif(notify_users, f'New mention of you by @{v.username}', c.body, (c.id,bool(c.wall_user_id)))
|
||||
push_notif(notify_users, f'New mention of you by @{v.username}', c.body, c)
|
||||
|
||||
if c.level == 1 and posting_to_submission:
|
||||
subscriber_ids = [x[0] for x in g.db.query(Subscription.user_id).filter(Subscription.submission_id == post_target.id, Subscription.user_id != v.id).all()]
|
||||
|
||||
notify_users.update(subscriber_ids)
|
||||
|
||||
push_notif(subscriber_ids, f'New comment in subscribed thread by @{v.username}', c.body, (c.id,bool(c.wall_user_id)))
|
||||
push_notif(subscriber_ids, f'New comment in subscribed thread by @{v.username}', c.body, c)
|
||||
|
||||
if parent_user.id != v.id:
|
||||
notify_users.add(parent_user.id)
|
||||
|
@ -443,7 +443,7 @@ def edit_comment(cid, v):
|
|||
n = Notification(comment_id=c.id, user_id=x)
|
||||
g.db.add(n)
|
||||
if not v.shadowbanned:
|
||||
push_notif({x}, f'New mention of you by @{v.username}', c.body, (c.id,bool(c.wall_user_id)))
|
||||
push_notif({x}, f'New mention of you by @{v.username}', c.body, c)
|
||||
|
||||
g.db.commit()
|
||||
return {"body": c.body, "comment": c.realbody(v)}
|
||||
|
|
Loading…
Reference in New Issue