forked from rDrama/rDrama
dont generate notifs that wont be seen
parent
9dc48c7acf
commit
d44bd1241c
|
@ -353,15 +353,14 @@ def messagereply(v):
|
||||||
execute_under_siege(v, c, c.body_html, 'message')
|
execute_under_siege(v, c, c.body_html, 'message')
|
||||||
|
|
||||||
if user_id and user_id not in {v.id, MODMAIL_ID} | BOT_IDs:
|
if user_id and user_id not in {v.id, MODMAIL_ID} | BOT_IDs:
|
||||||
notif = g.db.query(Notification).filter_by(comment_id=c.id, user_id=user_id).one_or_none()
|
if User.can_see(user, v):
|
||||||
if not notif:
|
notif = g.db.query(Notification).filter_by(comment_id=c.id, user_id=user_id).one_or_none()
|
||||||
notif = Notification(comment_id=c.id, user_id=user_id)
|
if not notif:
|
||||||
g.db.add(notif)
|
notif = Notification(comment_id=c.id, user_id=user_id)
|
||||||
|
g.db.add(notif)
|
||||||
|
|
||||||
title = f'New message from @{c.author_name}'
|
title = f'New message from @{c.author_name}'
|
||||||
|
|
||||||
url = f'{SITE_FULL}/notifications/messages'
|
url = f'{SITE_FULL}/notifications/messages'
|
||||||
|
|
||||||
push_notif({user_id}, title, body, url)
|
push_notif({user_id}, title, body, url)
|
||||||
|
|
||||||
top_comment = c.top_comment
|
top_comment = c.top_comment
|
||||||
|
|
|
@ -373,6 +373,9 @@ def comment(v):
|
||||||
if parent_user.id != v.id and notify_op:
|
if parent_user.id != v.id and notify_op:
|
||||||
notify_users.add(parent_user.id)
|
notify_users.add(parent_user.id)
|
||||||
|
|
||||||
|
if v.shadowbanned:
|
||||||
|
notify_users = [x[0] for x in g.db.query(User.id).filter(User.id.in_(notify_users), User.admin_level >= PERMS['USER_SHADOWBAN']).all()]
|
||||||
|
|
||||||
for x in notify_users-BOT_IDs:
|
for x in notify_users-BOT_IDs:
|
||||||
n = Notification(comment_id=c.id, user_id=x)
|
n = Notification(comment_id=c.id, user_id=x)
|
||||||
g.db.add(n)
|
g.db.add(n)
|
||||||
|
@ -723,6 +726,9 @@ def edit_comment(cid, v):
|
||||||
if notify_users == 'everyone':
|
if notify_users == 'everyone':
|
||||||
alert_everyone(c.id)
|
alert_everyone(c.id)
|
||||||
else:
|
else:
|
||||||
|
if v.shadowbanned:
|
||||||
|
notify_users = [x[0] for x in g.db.query(User.id).filter(User.id.in_(notify_users), User.admin_level >= PERMS['USER_SHADOWBAN']).all()]
|
||||||
|
|
||||||
for x in notify_users-BOT_IDs:
|
for x in notify_users-BOT_IDs:
|
||||||
notif = g.db.query(Notification).filter_by(comment_id=c.id, user_id=x).one_or_none()
|
notif = g.db.query(Notification).filter_by(comment_id=c.id, user_id=x).one_or_none()
|
||||||
if not notif:
|
if not notif:
|
||||||
|
|
|
@ -665,7 +665,7 @@ def message2(v, username=None, id=None):
|
||||||
execute_under_siege(v, c, c.body_html, 'message')
|
execute_under_siege(v, c, c.body_html, 'message')
|
||||||
c.top_comment_id = c.id
|
c.top_comment_id = c.id
|
||||||
|
|
||||||
if user.id not in BOT_IDs:
|
if user.id not in BOT_IDs and User.can_see(user, v):
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
notif = g.db.query(Notification).filter_by(comment_id=c.id, user_id=user.id).one_or_none()
|
notif = g.db.query(Notification).filter_by(comment_id=c.id, user_id=user.id).one_or_none()
|
||||||
if not notif:
|
if not notif:
|
||||||
|
|
Loading…
Reference in New Issue