remove unused JL0 perms (bloat)

pull/198/head
Aevann 2023-09-05 15:30:16 +03:00
parent 6f0211be58
commit 462bb23e6d
7 changed files with 20 additions and 48 deletions

View File

@ -349,10 +349,6 @@ SUB_MARSEY_URL_LENGTH = 60
PERMS = { # Minimum admin_level to perform action.
'HOLE_CREATE': 0,
'USER_BLOCKS_VISIBLE': 0,
'USER_FOLLOWS_VISIBLE': 0,
'USER_VOTERS_VISIBLE': 0,
'VIEW_PENDING_SUBMITTED_EMOJIS': 0,
'POST_COMMENT_DISTINGUISH': 1,
'POST_IN_GHOST_THREADS': 1,

View File

@ -23,10 +23,7 @@ def submit_marseys_redirect():
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
@auth_required
def submit_emojis(v):
if v.admin_level >= PERMS['VIEW_PENDING_SUBMITTED_EMOJIS']:
emojis = g.db.query(Emoji).filter(Emoji.submitter_id != None)
else:
emojis = g.db.query(Emoji).filter(Emoji.submitter_id == v.id)
emojis = g.db.query(Emoji).filter(Emoji.submitter_id != None)
emojis = emojis.order_by(Emoji.created_utc.desc()).all()

View File

@ -679,8 +679,7 @@ def settings_block_user(v):
new_block = UserBlock(user_id=v.id, target_id=user.id)
g.db.add(new_block)
if user.admin_level >= PERMS['USER_BLOCKS_VISIBLE']:
send_notification(user.id, f"@{v.username} has blocked you!")
send_notification(user.id, f"@{v.username} has blocked you!")
cache.delete_memoized(frontlist)
return {"message": f"@{user.username} blocked!"}
@ -697,8 +696,9 @@ def settings_unblock_user(v):
x = v.has_blocked(user)
if not x: abort(409, "You can't unblock someone you haven't blocked")
g.db.delete(x)
if not v.shadowbanned and user.admin_level >= PERMS['USER_BLOCKS_VISIBLE']:
send_notification(user.id, f"@{v.username} has unblocked you!")
send_notification(user.id, f"@{v.username} has unblocked you!")
cache.delete_memoized(frontlist)
return {"message": f"@{user.username} unblocked successfully!"}

View File

@ -340,7 +340,7 @@ def badges(v):
@app.get("/blocks")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
@admin_level_required(PERMS['USER_BLOCKS_VISIBLE'])
@auth_required
def blocks(v):
blocks = g.db.query(UserBlock).options(
joinedload(UserBlock.user),

View File

@ -147,7 +147,6 @@ def transfer_currency(v, username, currency_name, apply_tax):
def upvoters_downvoters(v, username, username2, cls, vote_cls, vote_dir, template, standalone):
u = get_user(username, v=v)
if not u.is_visible_to(v): abort(403)
if not (v.id == u.id or v.admin_level >= PERMS['USER_VOTERS_VISIBLE']): abort(403)
id = u.id
uid = get_user(username2, id_only=True).id
@ -211,7 +210,6 @@ def downvoters_comments(v, username, username2):
def upvoting_downvoting(v, username, username2, cls, vote_cls, vote_dir, template, standalone):
u = get_user(username, v=v)
if not u.is_visible_to(v): abort(403)
if not (v.id == u.id or v.admin_level >= PERMS['USER_VOTERS_VISIBLE']): abort(403)
id = u.id
uid = get_user(username2, id_only=True).id
@ -275,7 +273,6 @@ def downvoting_comments(v, username, username2):
def user_voted(v, username, cls, vote_cls, template, standalone):
u = get_user(username, v=v)
if not u.is_visible_to(v): abort(403)
if not (v.id == u.id or v.admin_level >= PERMS['USER_VOTERS_VISIBLE']): abort(403)
page = get_page()
@ -372,8 +369,6 @@ def all_upvoters_downvoters(v, username, vote_dir, is_who_simps_hates):
vote_name = 'Down'
id = get_user(username, v=v).id
if not (v.id == id or v.admin_level >= PERMS['USER_VOTERS_VISIBLE']):
abort(403)
votes = []
votes2 = []
if is_who_simps_hates:
@ -874,9 +869,6 @@ def blocking(v, username):
def followers(v, username):
u = get_user(username, v=v)
if not (v.id == u.id or v.admin_level >= PERMS['USER_FOLLOWS_VISIBLE']):
abort(403)
page = get_page()
users = g.db.query(Follow, User).join(Follow, Follow.target_id == u.id) \
@ -896,9 +888,6 @@ def followers(v, username):
def following(v, username):
u = get_user(username, v=v)
if not (v.id == u.id or v.admin_level >= PERMS['USER_FOLLOWS_VISIBLE']):
abort(403)
page = get_page()
users = g.db.query(Follow, User).join(Follow, Follow.user_id == u.id) \

View File

@ -26,11 +26,9 @@
<li class="nav-item">
<a class="nav-link{% if request.path == '/banned' %} active{% endif %}" href="/banned"><i class="fas fa-user-slash pr-2"></i>Banned Users</a>
</li>
{% if v and v.admin_level >= PERMS['USER_BLOCKS_VISIBLE'] -%}
<li class="nav-item">
<a class="nav-link{% if request.path == '/blocks' %} active{% endif %}" href="/blocks"><i class="fas fa-eye-slash pr-2"></i>Blocks</a>
</li>
{%- endif %}
<li class="nav-item">
<a class="nav-link" href="/post/{{CHANGELOG_THREAD}}"><i class="fas fa-clipboard pr-2"></i>Changelog</a>
</li>

View File

@ -70,7 +70,6 @@
<p class="font-weight-bolder" id="profile--flair" style="color: #{{u.titlecolor}}">{{u.customtitle | safe}}</p>
{% endif %}
{% if v and (v.id == u.id or v.admin_level >= PERMS['USER_VOTERS_VISIBLE']) -%}
<div class="font-weight-bolder mb-2" id="profile--simphate">
<a class="mr-1" href="/@{{u.username}}/views">Profile Views</a> |
<a class="mx-1" href="/@{{u.username}}/upvoters">Simps</a> |
@ -78,19 +77,16 @@
<a class="mx-1" href="/@{{u.username}}/upvoting">Simps For</a> |
<a class="mx-1" href="/@{{u.username}}/downvoting">Hates</a> |
<a class="mx-1" href="/@{{u.username}}/voted/posts">Voted</a>
{%- endif %}
<div class="font-weight-bolder mb-1">
<div class="my-2">
{% if PERMS['USER_FOLLOWS_VISIBLE'] == 0 or (v and v.admin_level >= PERMS['USER_FOLLOWS_VISIBLE']) -%}
<a class="mr-1" href="/@{{u.username}}/followers" id="profile--followers">{{u.stored_subscriber_count}} follower{{'s' if u.stored_subscriber_count != 1 else ''}}</a> |
<a class="mr-1" href="/@{{u.username}}/followers" id="profile--followers">{{u.stored_subscriber_count}} follower{{'s' if u.stored_subscriber_count != 1 else ''}}</a> |
<a class="mx-1" href="/@{{u.username}}/following" id="profile--following">follows {{u.follow_count}} user{{'s' if u.follow_count != 1 else ''}}</a> |
<a class="mx-1" href="/@{{u.username}}/following" id="profile--following">follows {{u.follow_count}} user{{'s' if u.follow_count != 1 else ''}}</a> |
<a class="mx-1" href="/@{{u.username}}/blockers" id="profile--blockers">{{u.blocking_count}} blocker{{'s' if u.blocking_count != 1 else ''}}</a> |
<a class="mx-1" href="/@{{u.username}}/blockers" id="profile--blockers">{{u.blocking_count}} blocker{{'s' if u.blocking_count != 1 else ''}}</a> |
<a class="mx-1" href="/@{{u.username}}/blocking" id="profile--blocking">blocks {{u.block_count}} user{{'s' if u.block_count != 1 else ''}}</a>
{%- endif %}
<a class="mx-1" href="/@{{u.username}}/blocking" id="profile--blocking">blocks {{u.block_count}} user{{'s' if u.block_count != 1 else ''}}</a>
</div>
<span id="profile-coins-amount">{{u.coins}}</span>
@ -343,24 +339,20 @@
<p style="color: #{{u.titlecolor}}" id="profile-mobile--flair">{{u.customtitle | safe}}</p>
{% endif %}
{% if v and (v.id == u.id or v.admin_level >= PERMS['USER_VOTERS_VISIBLE']) -%}
<div class="font-weight-bolder mb-2" id="profile-mobile--simphate">
<a class="mr-1" href="/@{{u.username}}/views">Profile Views</a> |
<a class="mx-1" href="/@{{u.username}}/upvoters">Simps</a> |
<a class="mx-1" href="/@{{u.username}}/downvoters">Haters</a> |
<a class="mx-1" href="/@{{u.username}}/upvoting">Simps For</a> |
<a class="mx-1" href="/@{{u.username}}/downvoting">Hates</a> |
<a class="mx-1" href="/@{{u.username}}/voted/posts">Voted</a>
</div>
{%- endif %}
<div class="font-weight-bolder mb-2" id="profile-mobile--simphate">
<a class="mr-1" href="/@{{u.username}}/views">Profile Views</a> |
<a class="mx-1" href="/@{{u.username}}/upvoters">Simps</a> |
<a class="mx-1" href="/@{{u.username}}/downvoters">Haters</a> |
<a class="mx-1" href="/@{{u.username}}/upvoting">Simps For</a> |
<a class="mx-1" href="/@{{u.username}}/downvoting">Hates</a> |
<a class="mx-1" href="/@{{u.username}}/voted/posts">Voted</a>
</div>
<div class="font-weight-bolder">
<div>
{% if PERMS['USER_FOLLOWS_VISIBLE'] == 0 or (v and v.admin_level >= PERMS['USER_FOLLOWS_VISIBLE']) -%}
<a class="mr-1" href="/@{{u.username}}/followers" id="profile-mobile--followers">{{u.stored_subscriber_count}} follower{{'s' if u.stored_subscriber_count != 1 else ''}}</a>
<a class="mr-1" href="/@{{u.username}}/followers" id="profile-mobile--followers">{{u.stored_subscriber_count}} follower{{'s' if u.stored_subscriber_count != 1 else ''}}</a>
<a class="mx-1" href="/@{{u.username}}/following" id="profile-mobile--following"> follows {{u.follow_count}} user{{'s' if u.follow_count != 1 else ''}}</a>
{%- endif %}
<a class="mx-1" href="/@{{u.username}}/following" id="profile-mobile--following"> follows {{u.follow_count}} user{{'s' if u.follow_count != 1 else ''}}</a>
</div>
<div class="mb-2">