rename some perms

pull/198/head
Aevann 2023-08-31 13:38:01 +03:00
parent 7ce4e34453
commit df45eb3c57
6 changed files with 17 additions and 17 deletions

View File

@ -273,7 +273,7 @@ class User(Base):
@property
@lazy
def allowed_in_chat(self):
if self.admin_level >= PERMS['SITE_BYPASS_CHAT_TRUESCORE_REQUIREMENT']:
if self.admin_level >= PERMS['BYPASS_CHAT_TRUESCORE_REQUIREMENT']:
return True
if self.truescore >= TRUESCORE_CC_CHAT_MINIMUM:
return True

View File

@ -376,7 +376,7 @@ def tempban_for_spam(v):
def execute_antispam_post_check(title, v, url):
if v.admin_level >= PERMS['SITE_BYPASS_ANTISPAM_CHECKS']:
if v.admin_level >= PERMS['BYPASS_ANTISPAM_CHECKS']:
return True
now = int(time.time())
@ -419,7 +419,7 @@ def execute_antispam_post_check(title, v, url):
return True
def execute_antispam_duplicate_comment_check(v, body_html):
if v.admin_level >= PERMS['SITE_BYPASS_ANTISPAM_CHECKS']:
if v.admin_level >= PERMS['BYPASS_ANTISPAM_CHECKS']:
return
if v.id in ANTISPAM_BYPASS_IDS:
return
@ -440,7 +440,7 @@ def execute_antispam_duplicate_comment_check(v, body_html):
abort(403, "Too much spam!")
def execute_antispam_comment_check(body, v):
if v.admin_level >= PERMS['SITE_BYPASS_ANTISPAM_CHECKS']:
if v.admin_level >= PERMS['BYPASS_ANTISPAM_CHECKS']:
return
if v.id in ANTISPAM_BYPASS_IDS: return
@ -500,7 +500,7 @@ def execute_under_siege(v, target, body, kind):
if kind != 'post': return
if not get_setting("under_siege"): return
if v.admin_level >= PERMS['SITE_BYPASS_UNDER_SIEGE_MODE']: return
if v.admin_level >= PERMS['BYPASS_UNDER_SIEGE_MODE']: return
if kind in {'message', 'report'} and SITE == 'rdrama.net':
threshold = 86400

View File

@ -353,12 +353,12 @@ PERMS = { # Minimum admin_level to perform action.
'POST_COMMENT_DISTINGUISH': 1,
'POST_IN_GHOST_THREADS': 1,
'VIEW_RESTRICTED_HOLES': 1,
'SITE_BYPASS_READ_ONLY_MODE': 1,
'SITE_BYPASS_UNDER_SIEGE_MODE': 1,
'SITE_BYPASS_CHAT_TRUESCORE_REQUIREMENT': 1,
'SITE_BYPASS_ANTISPAM_CHECKS': 1,
'SITE_BYPASS_PROFILE_VIEWS': 1,
'SITE_WARN_ON_INVALID_AUTH': 1,
'BYPASS_SITE_READ_ONLY_MODE': 1,
'BYPASS_UNDER_SIEGE_MODE': 1,
'BYPASS_CHAT_TRUESCORE_REQUIREMENT': 1,
'BYPASS_ANTISPAM_CHECKS': 1,
'BYPASS_PROFILE_VIEWS': 1,
'WARN_ON_FAILED_LOGIN': 1,
'NOTIFICATIONS_REDDIT': 1,
'NOTIFICATIONS_SPECIFIC_WPD_COMMENTS': 1,
'MESSAGE_BLOCKED_USERS': 1,

View File

@ -105,7 +105,7 @@ def login_post(v):
return redirect('/')
def log_failed_admin_login_attempt(account, type):
if not account or account.admin_level < PERMS['SITE_WARN_ON_INVALID_AUTH']: return
if not account or account.admin_level < PERMS['WARN_ON_FAILED_LOGIN']: return
ip = get_CF()
print(f"A site admin from {ip} failed to login to account @{account.user_name} (invalid {type})")
t = time.strftime("%d/%B/%Y %H:%M:%S UTC", time.gmtime(time.time()))

View File

@ -950,7 +950,7 @@ def u_username_wall(v, username):
is_following = v and u.has_follower(v)
if v and v.id != u.id and v.admin_level < PERMS['SITE_BYPASS_PROFILE_VIEWS'] and not session.get("GLOBAL"):
if v and v.id != u.id and v.admin_level < PERMS['BYPASS_PROFILE_VIEWS'] and not session.get("GLOBAL"):
gevent.spawn(_add_profile_view, v.id, u.id)
page = get_page()
@ -997,7 +997,7 @@ def u_username_wall_comment(v, username, cid):
is_following = v and u.has_follower(v)
if v and v.id != u.id and v.admin_level < PERMS['SITE_BYPASS_PROFILE_VIEWS'] and not session.get("GLOBAL"):
if v and v.id != u.id and v.admin_level < PERMS['BYPASS_PROFILE_VIEWS'] and not session.get("GLOBAL"):
gevent.spawn(_add_profile_view, v.id, u.id)
if v and request.values.get("read"):
@ -1042,7 +1042,7 @@ def u_username(v, username):
abort(403, f"@{u.username}'s userpage is private")
return render_template("userpage/private.html", u=u, v=v, is_following=is_following), 403
if v and v.id != u.id and v.admin_level < PERMS['SITE_BYPASS_PROFILE_VIEWS'] and not session.get("GLOBAL"):
if v and v.id != u.id and v.admin_level < PERMS['BYPASS_PROFILE_VIEWS'] and not session.get("GLOBAL"):
gevent.spawn(_add_profile_view, v.id, u.id)
sort = request.values.get("sort", "new")
@ -1109,7 +1109,7 @@ def u_username_comments(username, v):
abort(403, f"@{u.username}'s userpage is private")
return render_template("userpage/private.html", u=u, v=v, is_following=is_following), 403
if v and v.id != u.id and v.admin_level < PERMS['SITE_BYPASS_PROFILE_VIEWS'] and not session.get("GLOBAL"):
if v and v.id != u.id and v.admin_level < PERMS['BYPASS_PROFILE_VIEWS'] and not session.get("GLOBAL"):
gevent.spawn(_add_profile_view, v.id, u.id)
page = get_page()

View File

@ -100,7 +100,7 @@ def get_logged_in_user():
else:
session.pop("lo_user")
if request.method.lower() != "get" and get_setting('read_only_mode') and not (v and v.admin_level >= PERMS['SITE_BYPASS_READ_ONLY_MODE']):
if request.method.lower() != "get" and get_setting('read_only_mode') and not (v and v.admin_level >= PERMS['BYPASS_SITE_READ_ONLY_MODE']):
abort(403, "Site is in read-only mode right now. It will be back shortly!")
if get_setting('offline_mode') and not (v and v.admin_level >= PERMS['SITE_OFFLINE_MODE']):