forked from rDrama/rDrama
1
0
Fork 0

use can_see_shadowbanned

master
Aevann 2023-10-05 12:44:42 +03:00
parent 2f9a5a30bf
commit 74587b12da
13 changed files with 23 additions and 23 deletions

View File

@ -1264,7 +1264,7 @@ class User(Base):
@property
@lazy
def can_see_shadowbanned(self):
return (self.admin_level >= PERMS['USER_SHADOWBAN'])
return (self.can_see_shadowbanned)
@property
@lazy

View File

@ -227,7 +227,7 @@ def NOTIFY_USERS(text, v, oldtext=None, ghost=False, log_cost=None, followers_pi
def push_notif(uids, title, body, url_or_comment):
if hasattr(g, 'v') and g.v and g.v.shadowbanned:
uids = [x[0] for x in g.db.query(User.id).filter(User.id.in_(uids), User.admin_level >= PERMS['USER_SHADOWBAN']).all()]
uids = [x[0] for x in g.db.query(User.id).filter(User.id.in_(uids), User.can_see_shadowbanned).all()]
if not uids:
return

View File

@ -374,7 +374,7 @@ def comment(v):
notify_users.add(parent_user.id)
if v.shadowbanned:
notify_users = [x[0] for x in g.db.query(User.id).filter(User.id.in_(notify_users), User.admin_level >= PERMS['USER_SHADOWBAN']).all()]
notify_users = [x[0] for x in g.db.query(User.id).filter(User.id.in_(notify_users), User.can_see_shadowbanned).all()]
for x in notify_users-BOT_IDs:
n = Notification(comment_id=c.id, user_id=x)
@ -727,7 +727,7 @@ def edit_comment(cid, v):
alert_everyone(c.id)
else:
if v.shadowbanned:
notify_users = [x[0] for x in g.db.query(User.id).filter(User.id.in_(notify_users), User.admin_level >= PERMS['USER_SHADOWBAN']).all()]
notify_users = [x[0] for x in g.db.query(User.id).filter(User.id.in_(notify_users), User.can_see_shadowbanned).all()]
for x in notify_users-BOT_IDs:
notif = g.db.query(Notification).filter_by(comment_id=c.id, user_id=x).one_or_none()

View File

@ -300,7 +300,7 @@ def notifications_reddit(v):
def notifications(v):
page = get_page()
if not session.get("GLOBAL") and v.admin_level < PERMS['USER_SHADOWBAN'] and not request.values.get('nr'):
if not session.get("GLOBAL") and not v.can_see_shadowbanned and not request.values.get('nr'):
unread_and_inaccessible = g.db.query(Notification).join(Notification.comment).join(Comment.author).filter(
Notification.user_id == v.id,
Notification.read == False,
@ -324,7 +324,7 @@ def notifications(v):
not_(and_(Comment.sentto != None, Comment.sentto == MODMAIL_ID, User.is_muted))
)
if v.admin_level < PERMS['USER_SHADOWBAN']:
if not v.can_see_shadowbanned:
comments = comments.filter(
Comment.is_banned == False,
Comment.deleted_utc == 0,

View File

@ -184,7 +184,7 @@ def log(v):
kind = request.values.get("kind")
if v.admin_level >= PERMS['USER_SHADOWBAN']:
if v.can_see_shadowbanned:
if v.admin_level >= PERMS['PROGSTACK']:
types = MODACTION_TYPES
else:
@ -197,7 +197,7 @@ def log(v):
total = 0
else:
actions = g.db.query(ModAction)
if v.admin_level < PERMS['USER_SHADOWBAN']:
if not v.can_see_shadowbanned:
actions = actions.filter(ModAction.kind.notin_(MODACTION_PRIVILEGED_TYPES))
if v.admin_level < PERMS['PROGSTACK']:
actions = actions.filter(ModAction.kind.notin_(MODACTION_PRIVILEGED__TYPES))
@ -226,12 +226,12 @@ def log_item(id, v):
if not action: abort(404)
if action.kind in MODACTION_PRIVILEGED_TYPES and v.admin_level < PERMS['USER_SHADOWBAN']:
if action.kind in MODACTION_PRIVILEGED_TYPES and not v.can_see_shadowbanned:
abort(404)
admins = [x[0] for x in g.db.query(User.username).filter(User.admin_level >= PERMS['ADMIN_MOP_VISIBLE'])]
if v.admin_level >= PERMS['USER_SHADOWBAN']:
if v.can_see_shadowbanned:
if v.admin_level >= PERMS['PROGSTACK']:
types = MODACTION_TYPES
else:

View File

@ -891,7 +891,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['USER_SHADOWBAN'] and not session.get("GLOBAL"):
if v and v.id != u.id and not v.can_see_shadowbanned and not session.get("GLOBAL"):
gevent.spawn(_add_profile_view, v.id, u.id)
page = get_page()
@ -938,7 +938,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['USER_SHADOWBAN'] and not session.get("GLOBAL"):
if v and v.id != u.id and not v.can_see_shadowbanned and not session.get("GLOBAL"):
gevent.spawn(_add_profile_view, v.id, u.id)
if v and request.values.get("read"):
@ -983,7 +983,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['USER_SHADOWBAN'] and not session.get("GLOBAL"):
if v and v.id != u.id and not v.can_see_shadowbanned and not session.get("GLOBAL"):
gevent.spawn(_add_profile_view, v.id, u.id)
sort = request.values.get("sort", "new")
@ -1050,7 +1050,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['USER_SHADOWBAN'] and not session.get("GLOBAL"):
if v and v.id != u.id and not v.can_see_shadowbanned and not session.get("GLOBAL"):
gevent.spawn(_add_profile_view, v.id, u.id)
page = get_page()

View File

@ -197,7 +197,7 @@ def vote_info_get(v, link):
if thing.ghost and v.admin_level < PERMS['SEE_GHOST_VOTES']:
abort(403)
if thing.author.shadowbanned and not (v and v.admin_level >= PERMS['USER_SHADOWBAN']):
if thing.author.shadowbanned and not (v and v.can_see_shadowbanned):
abort(500)
if isinstance(thing, Post):

View File

@ -57,7 +57,7 @@
<h4>Users</h4>
<ul>
{% if v.admin_level >= PERMS['USER_SHADOWBAN'] %}
{% if v.can_see_shadowbanned %}
<li><a href="/admin/shadowbanned">Shadowbanned Users</a></li>
{% endif %}
<li><a href="/banned">Banned Users</a></li>

View File

@ -17,7 +17,7 @@
{% set count=alts|length %}
<section class="userinfo-section">
<p><a href="/@{{u.username}}">@{{u.username}}</a> created their account {{u.created_utc|timestamp}} and has {{count}} known alt{{macros.plural(count)}}.<br>
They are {% if not u.is_permabanned %}not {% endif %}permanently banned{% if v.admin_level >= PERMS['USER_SHADOWBAN'] %} and they are {% if not u.shadowbanned %}not {% endif %}shadowbanned{% endif %}.</p>
They are {% if not u.is_permabanned %}not {% endif %}permanently banned{% if v.can_see_shadowbanned %} and they are {% if not u.shadowbanned %}not {% endif %}shadowbanned{% endif %}.</p>
</section>
<div class="overflow-x-auto">
<table class="table table-striped mb-5">

View File

@ -1 +1 @@
{% if v and v.admin_level >= PERMS['USER_SHADOWBAN'] and user.shadowbanned %}<i class="fas fa-user-times text-admin" data-bs-toggle="tooltip" data-bs-placement="bottom" title='Shadowbanned by @{{user.shadowbanner}} for "{{user.ban_reason}}"' data-bs-html="true"></i>{% endif %}
{% if v and v.can_see_shadowbanned and user.shadowbanned %}<i class="fas fa-user-times text-admin" data-bs-toggle="tooltip" data-bs-placement="bottom" title='Shadowbanned by @{{user.shadowbanner}} for "{{user.ban_reason}}"' data-bs-html="true"></i>{% endif %}

View File

@ -140,7 +140,7 @@
{% if c.active_reports(v) %}<button type="button" class="btn btn-primary mr-1" style="padding:1px 5px; font-size:10px" data-toggleelement="#reports-{{c.id}}" data-toggleattr="d-none">{{c.active_reports(v)}} Report{{macros.plural(c.active_reports(v))}}</button>{% endif %}
{% if c.over_18 %}<span class="badge badge-danger text-small-extra mr-1">NSFW</span>{% endif %}
{% if v and v.admin_level >= PERMS['USER_SHADOWBAN'] and c.author.shadowbanned %}<i class="fas fa-user-times text-admin" data-bs-toggle="tooltip" data-bs-placement="bottom" title='Shadowbanned by @{{c.author.shadowbanner}} for "{{c.author.ban_reason}}"' data-bs-html="true"></i>{% endif %}
{% if v and v.can_see_shadowbanned and c.author.shadowbanned %}<i class="fas fa-user-times text-admin" data-bs-toggle="tooltip" data-bs-placement="bottom" title='Shadowbanned by @{{c.author.shadowbanner}} for "{{c.author.ban_reason}}"' data-bs-html="true"></i>{% endif %}
{% if c.stickied %}
<i id='pinned-{{c.id}}'class="fas fa-thumbtack fa-rotate--45 pr-1 text-admin" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Pinned by @{{c.stickied}}" {% if c.stickied_utc %}data-onmouseover="pinned_timestamp('pinned-{{c.id}}')" data-timestamp={{c.stickied_utc}} data-nonce="{{g.nonce}}"{% endif %}></i>
{% endif %}

View File

@ -21,7 +21,7 @@
{% endif %}
</h5>
{% endif %}
{% if v and v.admin_level >= PERMS['USER_SHADOWBAN'] and u.shadowbanned %}
{% if v and v.can_see_shadowbanned and u.shadowbanned %}
<h5 class="text-primary" id="profile-{{deviceType}}--shadowbanned">SHADOWBANNED USER:
{{u.ban_reason | safe}}
@ -65,7 +65,7 @@
<button type="button" id="unban-{{deviceType}}" class="mt-1 {% if not u.is_suspended %}d-none{% endif %} btn btn-success" data-nonce="{{g.nonce}}" data-onclick="unchud_or_unban(this,'/unban_user/{{u.id}}')">Unban user</button>
{% endif %}
{% if v.admin_level >= PERMS['USER_SHADOWBAN'] %}
{% if v.can_see_shadowbanned %}
<form id="shadowban-{{deviceType}}" class="my-3 {% if u.shadowbanned %}d-none{% endif %}" action="/shadowban/{{u.id}}" method="post" data-nonce="{{g.nonce}}" data-onsubmit="sendFormXHRSwitch(this)">
<input hidden name="formkey" value="{{v|formkey}}">
<input autocomplete="off" style="font-size:11px" type="text" class="form-control" maxlength="256" name="reason" placeholder="Shadowban Reason" data-nonce="{{g.nonce}}" data-undisable_element="user-shadowban-submit-{{deviceType}}" required>

View File

@ -37,7 +37,7 @@
{% endif %}
{% endfor %}
{% if v and v.admin_level >= PERMS['USER_SHADOWBAN'] and p.author.shadowbanned %}
{% if v and v.can_see_shadowbanned and p.author.shadowbanned %}
<i class="fas fa-user-times text-admin" data-bs-toggle="tooltip" data-bs-placement="bottom" title='Shadowbanned by @{{p.author.shadowbanner}} for "{{p.author.ban_reason}}"' data-bs-html="true"></i>
{% endif %}
@ -205,7 +205,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 >= PERMS['USER_SHADOWBAN'] and r.user.shadowbanned %}
{% if v and v.can_see_shadowbanned 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>