global moderation perm and add some more checks for const perm

master
justcool393 2022-10-05 18:16:52 -07:00
parent 0dfff1f4f6
commit 4b78ed176a
4 changed files with 6 additions and 5 deletions

View File

@ -319,7 +319,7 @@ class User(Base):
@lazy @lazy
def mod_date(self, sub): def mod_date(self, sub):
if self.admin_level >= 3: return 1 if self.admin_level >= PERMS['GLOBAL_HOLE_MODERATION']: return 1
mod = g.db.query(Mod).filter_by(user_id=self.id, sub=sub).one_or_none() mod = g.db.query(Mod).filter_by(user_id=self.id, sub=sub).one_or_none()
if not mod: return None if not mod: return None
return mod.created_utc return mod.created_utc

View File

@ -128,6 +128,7 @@ PERMS = { # Minimum admin_level to perform action.
'USER_FOLLOWS_VISIBLE': 0, 'USER_FOLLOWS_VISIBLE': 0,
'USER_VOTERS_VISIBLE': 0, 'USER_VOTERS_VISIBLE': 0,
'POST_COMMENT_MODERATION': 2, 'POST_COMMENT_MODERATION': 2,
'GLOBAL_HOLE_MODERATION': 3,
} }
FEATURES = { FEATURES = {

View File

@ -30,7 +30,7 @@ def flag_post(pid, v):
if len(reason) > 350: return {"error": "Too long."}, 400 if len(reason) > 350: return {"error": "Too long."}, 400
if reason.startswith('!') and (v.admin_level > 1 or post.sub and v.mods(post.sub)): if reason.startswith('!') and (v.admin_level > PERMS['POST_COMMENT_MODERATION'] or post.sub and v.mods(post.sub)):
post.flair = reason[1:] post.flair = reason[1:]
g.db.add(post) g.db.add(post)
if v.admin_level > 1: if v.admin_level > 1:
@ -51,7 +51,7 @@ def flag_post(pid, v):
) )
g.db.add(ma) g.db.add(ma)
elif reason.startswith('/h/') and (v.admin_level >= 2 or v.id == post.author_id or (reason == '/h/chudrama' and v.mods(post.sub))): elif reason.startswith('/h/') and (v.admin_level >= PERMS['POST_COMMENT_MODERATION'] or v.id == post.author_id or (reason == '/h/chudrama' and v.mods(post.sub))):
sub_from = post.sub sub_from = post.sub
sub_to = reason[3:].strip().lower() sub_to = reason[3:].strip().lower()

View File

@ -1141,14 +1141,14 @@ def u_username_comments(username, v=None):
Comment.parent_submission != None Comment.parent_submission != None
) )
if not v or (v.id != u.id and v.admin_level < 2): if not v or (v.id != u.id and v.admin_level < PERMS['POST_COMMENT_MODERATION']):
comments = comments.filter( comments = comments.filter(
Comment.is_banned == False, Comment.is_banned == False,
Comment.ghost == False, Comment.ghost == False,
comment_post_author.shadowbanned == None comment_post_author.shadowbanned == None
) )
if not (v and v.admin_level > 1): if not (v and v.admin_level > PERMS['POST_COMMENT_MODERATION']):
comments = comments.filter(Comment.deleted_utc == 0) comments = comments.filter(Comment.deleted_utc == 0)
comments = apply_time_filter(t, comments, Comment) comments = apply_time_filter(t, comments, Comment)