disallow !followers ping in posts

pull/189/head
Aevann 2023-08-11 16:38:49 +03:00
parent 6f5872cf62
commit 7ab046474f
2 changed files with 6 additions and 4 deletions

View File

@ -120,7 +120,7 @@ def add_notif(cid, uid, text, pushnotif_url=''):
push_notif({uid}, 'New notification', text, pushnotif_url)
def NOTIFY_USERS(text, v, oldtext=None, ghost=False, log_cost=None):
def NOTIFY_USERS(text, v, oldtext=None, ghost=False, log_cost=None, followers_ping=True):
# Restrict young accounts from generating notifications
if v.age < NOTIFICATION_SPAM_AGE_THRESHOLD:
return set()
@ -165,6 +165,8 @@ def NOTIFY_USERS(text, v, oldtext=None, ghost=False, log_cost=None):
group = None
member_ids = set([x[0] for x in g.db.query(User.id).filter(User.admin_level > 0, User.id != AEVANN_ID)])
elif i.group(1) == 'followers':
if not followers_ping:
abort(403, f"You can't use !followers in posts!")
group = None
member_ids = set([x[0] for x in g.db.query(Follow.user_id).filter_by(target_id=v.id)])
else:

View File

@ -58,7 +58,7 @@ def publish(pid, v):
p.created_utc = int(time.time())
g.db.add(p)
notify_users = NOTIFY_USERS(f'{p.title} {p.body}', v, ghost=p.ghost, log_cost=p)
notify_users = NOTIFY_USERS(f'{p.title} {p.body}', v, ghost=p.ghost, log_cost=p, followers_ping=False)
if notify_users:
cid, text = notif_comment2(p)
@ -602,7 +602,7 @@ def submit_post(v, sub=None):
abort(415)
if not p.private:
notify_users = NOTIFY_USERS(f'{title} {body}', v, ghost=p.ghost, log_cost=p)
notify_users = NOTIFY_USERS(f'{title} {body}', v, ghost=p.ghost, log_cost=p, followers_ping=False)
if notify_users:
cid, text = notif_comment2(p)
@ -978,7 +978,7 @@ def edit_post(pid, v):
if not p.private:
notify_users = NOTIFY_USERS(f'{title} {body}', v, oldtext=f'{p.title} {p.body}', ghost=p.ghost, log_cost=p)
notify_users = NOTIFY_USERS(f'{title} {body}', v, oldtext=f'{p.title} {p.body}', ghost=p.ghost, log_cost=p, followers_ping=False)
if notify_users:
cid, text = notif_comment2(p)
if notify_users == 'everyone':