user PERMS whenever u can

pull/198/head
Aevann 2023-08-31 13:31:04 +03:00
parent 2827852203
commit 7ce4e34453
8 changed files with 31 additions and 24 deletions

View File

@ -273,9 +273,12 @@ class User(Base):
@property
@lazy
def allowed_in_chat(self):
if self.admin_level: return True
if self.truescore >= TRUESCORE_CC_CHAT_MINIMUM: return True
if self.patron: return True
if self.admin_level >= PERMS['SITE_BYPASS_CHAT_TRUESCORE_REQUIREMENT']:
return True
if self.truescore >= TRUESCORE_CC_CHAT_MINIMUM:
return True
if self.patron:
return True
return False
@property
@ -787,7 +790,7 @@ class User(Base):
if self.id == AEVANN_ID and SITE_NAME != 'rDrama':
return 0
if self.admin_level:
if self.admin_level >= PERMS['NOTIFICATIONS_MODERATOR_ACTIONS']:
q = g.db.query(ModAction).filter(
ModAction.created_utc > self.last_viewed_log_notifs,
ModAction.user_id != self.id,

View File

@ -376,7 +376,8 @@ def tempban_for_spam(v):
def execute_antispam_post_check(title, v, url):
if v.admin_level: return True
if v.admin_level >= PERMS['SITE_BYPASS_ANTISPAM_CHECKS']:
return True
now = int(time.time())
cutoff = now - 60 * 60 * 24
@ -418,15 +419,16 @@ def execute_antispam_post_check(title, v, url):
return True
def execute_antispam_duplicate_comment_check(v, body_html):
if v.admin_level: return
if v.admin_level >= PERMS['SITE_BYPASS_ANTISPAM_CHECKS']:
return
if v.id in ANTISPAM_BYPASS_IDS:
return
if v.age >= NOTIFICATION_SPAM_AGE_THRESHOLD:
return
if len(body_html) < 16:
return
'''
Sanity check for newfriends
'''
ANTISPAM_DUPLICATE_THRESHOLD = 3
if v.id in ANTISPAM_BYPASS_IDS or v.admin_level: return
if v.age >= NOTIFICATION_SPAM_AGE_THRESHOLD: return
if len(body_html) < 16: return
compare_time = int(time.time()) - 60 * 60 * 24
count = g.db.query(Comment.id).filter(Comment.body_html == body_html,
Comment.created_utc >= compare_time).count()
@ -438,7 +440,8 @@ 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: return
if v.admin_level >= PERMS['SITE_BYPASS_ANTISPAM_CHECKS']:
return
if v.id in ANTISPAM_BYPASS_IDS: return
if len(body) <= COMMENT_SPAM_LENGTH_THRESHOLD: return

View File

@ -355,6 +355,9 @@ PERMS = { # Minimum admin_level to perform action.
'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,
'NOTIFICATIONS_REDDIT': 1,
'NOTIFICATIONS_SPECIFIC_WPD_COMMENTS': 1,
@ -379,6 +382,7 @@ PERMS = { # Minimum admin_level to perform action.
'NOTIFICATIONS_HOLE_CREATION': 1,
'NOTIFICATIONS_MODERATOR_ACTIONS': 1,
'IS_PERMA_PROGSTACKED': 2,
'USER_BADGES': 2,
'USER_LINK': 2,
'USER_TITLE_CHANGE': 2,
@ -567,7 +571,6 @@ CARP_ID = 0
AEVANN_ID = 0
GTIX_ID = 0
LAWLZ_ID = 0
SCHIZO_ID = 0
IMMUNE_TO_AWARDS = {}
EXEMPT_FROM_1WEEK_EDITING_LIMIT = {}
@ -687,7 +690,6 @@ if SITE == 'rdrama.net':
CARP_ID = 995
AEVANN_ID = 1
LAWLZ_ID = 3833
SCHIZO_ID = 8494
IMMUNE_TO_AWARDS = {PIZZASHILL_ID, CARP_ID}
@ -700,7 +702,7 @@ if SITE == 'rdrama.net':
'clit': CARP_ID,
'impassionata': IMPASSIONATA_ID,
'pizzashill': PIZZASHILL_ID,
'schizo': SCHIZO_ID,
'schizo': 8494,
'joan': 28,
'pewkie': 28,

View File

@ -150,7 +150,6 @@ def award_thing(v, thing_type, id):
if v.shadowbanned: abort(500)
author = thing.author
if author.shadowbanned and not v.admin_level: abort(404)
AWARDS = deepcopy(AWARDS_ENABLED)
if v.house:

View File

@ -200,7 +200,7 @@ def move_post(post, v, reason):
sub_to_str = 'main feed' if sub_to is None else \
f'<a href="/h/{sub_to}">/h/{sub_to}</a>'
if v.admin_level:
if v.admin_level >= PERMS['POST_COMMENT_MODERATION']:
ma = ModAction(
kind='move_hole',
user_id=v.id,

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 not v.admin_level and not session.get("GLOBAL"):
if v and v.id != u.id and v.admin_level < PERMS['SITE_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 not v.admin_level and not session.get("GLOBAL"):
if v and v.id != u.id and v.admin_level < PERMS['SITE_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 not v.admin_level and not session.get("GLOBAL"):
if v and v.id != u.id and v.admin_level < PERMS['SITE_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 not v.admin_level and not session.get("GLOBAL"):
if v and v.id != u.id and v.admin_level < PERMS['SITE_BYPASS_PROFILE_VIEWS'] and not session.get("GLOBAL"):
gevent.spawn(_add_profile_view, v.id, u.id)
page = get_page()

View File

@ -127,7 +127,7 @@ def vote_post_comment(target_id, new, v, cls, vote_cls):
elif cls == Post and (any(i in target.title.lower() for i in ENCOURAGED) or any(i in str(target.url).lower() for i in ENCOURAGED2)):
mul = PROGSTACK_MUL
send_notification(AEVANN_ID, target.permalink)
elif target.author.progressivestack or (target.author.admin_level and target.author.id != SCHIZO_ID):
elif target.author.progressivestack or target.author.admin_level >= PERMS['IS_PERMA_PROGSTACKED']:
mul = 2
elif SITE == 'rdrama.net' and cls == Post:
if (target.domain.endswith('.win')

View File

@ -202,7 +202,7 @@
<ul class="mt-1 mb-0" style="padding-left:20px;word-wrap:break-word">
{% for r in i.filtered_reports(v) %}
<li>
{% if v and v.admin_level and r.user.shadowbanned %}
{% if v and v.admin_level >= PERMS['USER_SHADOWBAN'] and r.user.shadowbanned %}
<i class="fas fa-user-times text-admin" data-bs-toggle="tooltip" data-bs-placement="bottom" title='Shadowbanned by @{{r.user.shadowbanner}} for "{{r.user.ban_reason}}"' data-bs-html="true"></i>
{% endif %}
<a style="font-weight:bold" href="{{r.user.url}}">{{r.user.username}}</a>