notification settings and admin setting

master
justcool393 2022-10-05 21:40:02 -07:00
parent 3f1cc45a2b
commit 57b08043a4
4 changed files with 6 additions and 4 deletions

View File

@ -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 = {

View File

@ -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:

View File

@ -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'

View File

@ -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()