Aevann 2023-10-29 16:01:52 +03:00
parent 8272599137
commit fea0ab0b32
2 changed files with 8 additions and 0 deletions

View File

@ -417,6 +417,7 @@ class User(Base):
@lazy
def mods(self, hole):
if self.is_permabanned or self.shadowbanned: return False
if hole == 'test': return True
if self.admin_level >= PERMS['MODS_EVERY_HOLE']: return True
try:
return any(map(lambda x: x.hole == hole, self.hole_mods))

View File

@ -202,6 +202,9 @@ def unfollow_sub(v, hole):
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
@auth_required
def mods(v, hole):
if hole == 'test':
return redirect('/users')
hole = get_hole(hole)
if not can_see(v, hole):
abort(403)
@ -265,6 +268,10 @@ def hole_followers(v, hole):
@auth_required
def add_mod(v, hole):
if SITE_NAME == 'WPD': abort(403)
if hole == 'test':
abort(403, "Everyone is already a mod of this hole!")
hole = get_hole(hole).name
if not v.mods(hole): abort(403)