From 57b08043a47ad8fdbc29d699bef13262d84c8c50 Mon Sep 17 00:00:00 2001 From: justcool393 Date: Wed, 5 Oct 2022 21:40:02 -0700 Subject: [PATCH] notification settings and admin setting --- files/helpers/const.py | 2 ++ files/helpers/cron.py | 2 +- files/routes/admin.py | 2 +- files/routes/notifications.py | 4 ++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/files/helpers/const.py b/files/helpers/const.py index 76fece81d..673a25a50 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -160,6 +160,8 @@ PERMS = { # Minimum admin_level to perform action. 'CACHE_PURGE_CDN': 3, 'CACHE_DUMP_INTERNAL': 2, 'DOMAINS_BAN': 3, + 'NOTIFICATIONS_HOLE_INACTIVITY_DELETION': 2, + 'NOTIFICATIONS_FROM_SHADOWBANNED_USERS': 3, } FEATURES = { diff --git a/files/helpers/cron.py b/files/helpers/cron.py index e5b8a92ee..10c9ca52e 100644 --- a/files/helpers/cron.py +++ b/files/helpers/cron.py @@ -65,7 +65,7 @@ def sub_inactive_purge_task(): dead_holes = g.db.query(Sub).filter(Sub.name.notin_(active_holes)).all() names = [x.name for x in dead_holes] - admins = [x[0] for x in g.db.query(User.id).filter(User.admin_level > 1).all()] + admins = [x[0] for x in g.db.query(User.id).filter(User.admin_level >= PERMS['NOTIFICATIONS_HOLE_INACTIVITY_DELETION']).all()] mods = g.db.query(Mod).filter(Mod.sub.in_(names)).all() for x in mods: diff --git a/files/routes/admin.py b/files/routes/admin.py index 637b29a39..543989432 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -422,7 +422,7 @@ def reported_comments(v): def admin_home(v): under_attack = False - if v.admin_level > 2: + if v.admin_level >= PERMS['SITE_SETTINGS_UNDER_ATTACK']: if CF_ZONE == 'blahblahblah': response = 'high' else: response = requests.get(f'https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/settings/security_level', headers=CF_HEADERS, timeout=5).json()['result']['value'] under_attack = response == 'under_attack' diff --git a/files/routes/notifications.py b/files/routes/notifications.py index 900f79773..098ba10d4 100644 --- a/files/routes/notifications.py +++ b/files/routes/notifications.py @@ -75,7 +75,7 @@ def notifications_messages(v): Comment.parent_submission == None, Comment.level == 1, ) - if not v.shadowbanned and v.admin_level < 3: + if not v.shadowbanned and v.admin_level < PERMS['NOTIFICATIONS_FROM_SHADOWBANNED_USERS']: message_threads = message_threads.join(Comment.author) \ .filter(User.shadowbanned == None) @@ -258,7 +258,7 @@ def notifications(v): or_(Comment.sentto == None, Comment.sentto == 2), ).order_by(Notification.created_utc.desc()) - if not (v and (v.shadowbanned or v.admin_level >= 3)): + if not (v and (v.shadowbanned or v.admin_level >= PERMS['NOTIFICATIONS_FROM_SHADOWBANNED_USERS'])): comments = comments.join(Comment.author).filter(User.shadowbanned == None) comments = comments.offset(25 * (page - 1)).limit(26).all()