forked from rDrama/rDrama
allow jannies to get all kinds of notifs from shadowbanned users
parent
57b60e9128
commit
544adc4de6
|
@ -29,9 +29,11 @@ def create_comment(text_html):
|
|||
return new_comment.id
|
||||
|
||||
def send_repeatable_notification(uid, text):
|
||||
|
||||
if uid in BOT_IDs: return
|
||||
|
||||
if not (hasattr(g, 'v') and g.v and v.shadowbanned) or g.db.query(User.admin_level).filter_by(id=uid).one()[0] >= PERMS['USER_SHADOWBAN']:
|
||||
return
|
||||
|
||||
text_html = sanitize(text, blackjack="notification")
|
||||
|
||||
existing_comments = g.db.query(Comment.id).filter_by(author_id=AUTOJANNY_ID, parent_post=None, body_html=text_html, is_bot=True).order_by(Comment.id).all()
|
||||
|
@ -53,8 +55,11 @@ def send_repeatable_notification(uid, text):
|
|||
|
||||
|
||||
def send_notification(uid, text):
|
||||
|
||||
if uid in BOT_IDs: return
|
||||
|
||||
if not (hasattr(g, 'v') and g.v and v.shadowbanned) or g.db.query(User.admin_level).filter_by(id=uid).one()[0] >= PERMS['USER_SHADOWBAN']:
|
||||
return
|
||||
|
||||
cid = notif_comment(text)
|
||||
add_notif(cid, uid, text)
|
||||
|
||||
|
@ -161,7 +166,7 @@ def NOTIFY_USERS(text, v, oldtext=None, ghost=False, log_cost=None, followers_pi
|
|||
if oldtext and i.group(1) in oldtext:
|
||||
continue
|
||||
|
||||
if i.group(1) == 'everyone' and not v.shadowbanned:
|
||||
if i.group(1) == 'everyone':
|
||||
cost = g.db.query(User).count() * 5
|
||||
if cost > v.coins + v.marseybux:
|
||||
abort(403, f"You need {cost} currency to mention these ping groups!")
|
||||
|
@ -219,7 +224,9 @@ def NOTIFY_USERS(text, v, oldtext=None, ghost=False, log_cost=None, followers_pi
|
|||
|
||||
def push_notif(uids, title, body, url_or_comment):
|
||||
if hasattr(g, 'v') and g.v and g.v.shadowbanned:
|
||||
return
|
||||
uids = g.db.query(User.id).filter(User.id.in_(uids), User.admin_level >= PERMS['USER_SHADOWBAN']).all()
|
||||
if not uids:
|
||||
return
|
||||
|
||||
if VAPID_PUBLIC_KEY == DEFAULT_CONFIG_VALUE:
|
||||
return
|
||||
|
|
|
@ -356,38 +356,37 @@ def comment(v):
|
|||
execute_longpostbot(c, level, body, body_html, post_target, v)
|
||||
execute_zozbot(c, level, post_target, v)
|
||||
|
||||
if not v.shadowbanned:
|
||||
notify_users = NOTIFY_USERS(body, v, ghost=c.ghost, log_cost=c, commenters_ping_post_id=commenters_ping_post_id)
|
||||
notify_users = NOTIFY_USERS(body, v, ghost=c.ghost, log_cost=c, commenters_ping_post_id=commenters_ping_post_id)
|
||||
|
||||
if notify_users == 'everyone':
|
||||
alert_everyone(c.id)
|
||||
else:
|
||||
push_notif(notify_users, f'New mention of you by @{c.author_name}', c.body, c)
|
||||
if notify_users == 'everyone':
|
||||
alert_everyone(c.id)
|
||||
else:
|
||||
push_notif(notify_users, f'New mention of you by @{c.author_name}', c.body, c)
|
||||
|
||||
if c.level == 1 and posting_to_post:
|
||||
subscriber_ids = [x[0] for x in g.db.query(Subscription.user_id).filter(Subscription.post_id == post_target.id, Subscription.user_id != v.id)]
|
||||
if c.level == 1 and posting_to_post:
|
||||
subscriber_ids = [x[0] for x in g.db.query(Subscription.user_id).filter(Subscription.post_id == post_target.id, Subscription.user_id != v.id)]
|
||||
|
||||
notify_users.update(subscriber_ids)
|
||||
notify_users.update(subscriber_ids)
|
||||
|
||||
push_notif(subscriber_ids, f'New comment in subscribed thread by @{c.author_name}', c.body, c)
|
||||
push_notif(subscriber_ids, f'New comment in subscribed thread by @{c.author_name}', c.body, c)
|
||||
|
||||
if parent_user.id != v.id and notify_op:
|
||||
notify_users.add(parent_user.id)
|
||||
if parent_user.id != v.id and notify_op:
|
||||
notify_users.add(parent_user.id)
|
||||
|
||||
for x in notify_users-BOT_IDs:
|
||||
n = Notification(comment_id=c.id, user_id=x)
|
||||
g.db.add(n)
|
||||
for x in notify_users-BOT_IDs:
|
||||
n = Notification(comment_id=c.id, user_id=x)
|
||||
g.db.add(n)
|
||||
|
||||
if parent_user.id != v.id and notify_op:
|
||||
if isinstance(parent, User):
|
||||
title = f"New comment on your wall by @{c.author_name}"
|
||||
else:
|
||||
title = f'New reply by @{c.author_name}'
|
||||
if parent_user.id != v.id and notify_op:
|
||||
if isinstance(parent, User):
|
||||
title = f"New comment on your wall by @{c.author_name}"
|
||||
else:
|
||||
title = f'New reply by @{c.author_name}'
|
||||
|
||||
if len(c.body) > PUSH_NOTIF_LIMIT: notifbody = c.body[:PUSH_NOTIF_LIMIT] + '...'
|
||||
else: notifbody = c.body
|
||||
if len(c.body) > PUSH_NOTIF_LIMIT: notifbody = c.body[:PUSH_NOTIF_LIMIT] + '...'
|
||||
else: notifbody = c.body
|
||||
|
||||
push_notif({parent_user.id}, title, notifbody, c)
|
||||
push_notif({parent_user.id}, title, notifbody, c)
|
||||
|
||||
vote = CommentVote(user_id=v.id,
|
||||
comment_id=c.id,
|
||||
|
|
|
@ -67,7 +67,7 @@ def report_post(pid, v):
|
|||
report = Report(post_id=post.id, user_id=v.id, reason=reason_html)
|
||||
g.db.add(report)
|
||||
|
||||
if v.id != post.author_id and not v.shadowbanned and not post.author.has_blocked(v):
|
||||
if v.id != post.author_id and not post.author.has_blocked(v):
|
||||
message = f'@{v.username} reported [{post.title}]({post.shortlink})\n\n> {reason}'
|
||||
send_repeatable_notification(post.author_id, message)
|
||||
|
||||
|
@ -99,7 +99,7 @@ def report_comment(cid, v):
|
|||
report = CommentReport(comment_id=comment.id, user_id=v.id, reason=reason_html)
|
||||
g.db.add(report)
|
||||
|
||||
if v.id != comment.author_id and not v.shadowbanned and not comment.author.has_blocked(v):
|
||||
if v.id != comment.author_id and not comment.author.has_blocked(v):
|
||||
message = f'@{v.username} reported your [comment]({comment.shortlink})\n\n> {reason}'
|
||||
send_repeatable_notification(comment.author_id, message)
|
||||
|
||||
|
|
|
@ -667,9 +667,8 @@ def settings_block_user(v):
|
|||
user = get_user(request.values.get("username"))
|
||||
|
||||
if user.unblockable:
|
||||
if not v.shadowbanned:
|
||||
send_notification(user.id, f"@{v.username} has tried to block you and failed because of your unblockable status!")
|
||||
g.db.commit()
|
||||
send_notification(user.id, f"@{v.username} has tried to block you and failed because of your unblockable status!")
|
||||
g.db.commit()
|
||||
abort(403, f"@{user.username} is unblockable!")
|
||||
|
||||
if user.id == v.id: abort(400, "You can't block yourself")
|
||||
|
|
|
@ -139,16 +139,15 @@ def transfer_currency(v, username, currency_name, apply_tax):
|
|||
if not v.charge_account(currency_name, amount)[0]:
|
||||
abort(400, f"You don't have enough {currency_name}")
|
||||
|
||||
if not v.shadowbanned:
|
||||
if currency_name == 'marseybux':
|
||||
receiver.pay_account('marseybux', amount - tax)
|
||||
elif currency_name == 'coins':
|
||||
receiver.pay_account('coins', amount - tax)
|
||||
else:
|
||||
raise ValueError(f"Invalid currency '{currency_name}' got when transferring {amount} from {v.id} to {receiver.id}")
|
||||
if GIFT_NOTIF_ID: send_repeatable_notification(GIFT_NOTIF_ID, log_message)
|
||||
send_repeatable_notification(receiver.id, notif_text)
|
||||
g.db.add(v)
|
||||
if currency_name == 'marseybux':
|
||||
receiver.pay_account('marseybux', amount - tax)
|
||||
elif currency_name == 'coins':
|
||||
receiver.pay_account('coins', amount - tax)
|
||||
else:
|
||||
raise ValueError(f"Invalid currency '{currency_name}' got when transferring {amount} from {v.id} to {receiver.id}")
|
||||
if GIFT_NOTIF_ID: send_repeatable_notification(GIFT_NOTIF_ID, log_message)
|
||||
send_repeatable_notification(receiver.id, notif_text)
|
||||
|
||||
return {"message": f"{amount - tax} {currency_name} have been transferred to @{receiver.username}"}
|
||||
|
||||
def upvoters_downvoters(v, username, username2, cls, vote_cls, vote_dir, template, standalone):
|
||||
|
@ -449,8 +448,7 @@ def downvoting(v, username):
|
|||
def suicide(v, username):
|
||||
user = get_user(username)
|
||||
suicide = f"Hi there,\n\nA [concerned user](/id/{v.id}) reached out to us about you.\n\nWhen you're in the middle of something painful, it may feel like you don't have a lot of options. But whatever you're going through, you deserve help and there are people who are here for you.\n\nThere are resources available in your area that are free, confidential, and available 24/7:\n\n- Call, Text, or Chat with Canada's [Crisis Services Canada](https://www.crisisservicescanada.ca/en/)\n\n- Call, Email, or Visit the UK's [Samaritans](https://www.samaritans.org/)\n\n- Text CHAT to America's [Crisis Text Line](https://www.crisistextline.org/) at 741741.\n\nIf you don't see a resource in your area above, the moderators keep a comprehensive list of resources and hotlines for people organized by location. Find Someone Now\n\nIf you think you may be depressed or struggling in another way, don't ignore it or brush it aside. Take yourself and your feelings seriously, and reach out to someone.\n\nIt may not feel like it, but you have options. There are people available to listen to you, and ways to move forward.\n\nYour fellow users care about you and there are people who want to help."
|
||||
if not v.shadowbanned:
|
||||
send_notification(user.id, suicide)
|
||||
send_notification(user.id, suicide)
|
||||
return {"message": f"Help message sent to @{user.username}"}
|
||||
|
||||
|
||||
|
@ -1145,8 +1143,7 @@ def follow_user(username, v):
|
|||
target.stored_subscriber_count += 1
|
||||
g.db.add(target)
|
||||
|
||||
if not v.shadowbanned:
|
||||
send_notification(target.id, f"@{v.username} has followed you!")
|
||||
send_notification(target.id, f"@{v.username} has followed you!")
|
||||
|
||||
|
||||
return {"message": f"@{target.username} has been followed!"}
|
||||
|
@ -1169,8 +1166,7 @@ def unfollow_user(username, v):
|
|||
target.stored_subscriber_count -= 1
|
||||
g.db.add(target)
|
||||
|
||||
if not v.shadowbanned:
|
||||
send_notification(target.id, f"@{v.username} has unfollowed you!")
|
||||
send_notification(target.id, f"@{v.username} has unfollowed you!")
|
||||
|
||||
else:
|
||||
abort(400, f"You're not even following @{target.username} to begin with!")
|
||||
|
|
Loading…
Reference in New Issue