use ban_reason column as a reason for shadowbanning too

master
Aevann1 2022-09-29 08:36:59 +02:00
parent 2f16510183
commit 03e925fb3c
6 changed files with 79 additions and 31 deletions

View File

@ -910,23 +910,28 @@ def shadowban(user_id, v):
user = get_account(user_id)
if user.admin_level != 0: abort(403)
user.shadowbanned = v.username
reason = request.values.get("reason").strip()[:256]
user.ban_reason = reason
g.db.add(user)
if request.values.get("alts"):
for alt in user.alts:
if alt.admin_level: continue
alt.shadowbanned = v.username
alt.ban_reason = reason
g.db.add(alt)
ma = ModAction(
kind="shadowban",
user_id=v.id,
target_user_id=user.id,
_note=f'reason: "{reason}"'
)
g.db.add(ma)
cache.delete_memoized(frontlist)
return {"message": f"@{user.username} has been shadowbanned!"}
return redirect(user.url)
@app.post("/unshadowban/<user_id>")
@limiter.limit("1/second;30/minute;200/hour;1000/day")
@ -934,9 +939,11 @@ def shadowban(user_id, v):
def unshadowban(user_id, v):
user = get_account(user_id)
user.shadowbanned = None
if not user.is_banned: user.ban_reason = None
g.db.add(user)
for alt in user.alts:
alt.shadowbanned = None
if not alt.is_banned: alt.ban_reason = None
g.db.add(alt)
ma = ModAction(
@ -948,7 +955,7 @@ def unshadowban(user_id, v):
cache.delete_memoized(frontlist)
return {"message": f"@{user.username} has been unshadowbanned!"}
return redirect(user.url)
@app.post("/admin/title_change/<user_id>")
@ -996,7 +1003,7 @@ def ban_user(user_id, v):
days = float(request.values.get("days")) if request.values.get('days') else 0
reason = request.values.get("reason", "").strip()[:256]
reason = request.values.get("reason").strip()[:256]
reason = filter_emojis_only(reason)
if reason.startswith("/") and '\\' not in reason:
@ -1429,7 +1436,7 @@ def admin_toggle_ban_domain(v):
domain=request.values.get("domain", "").strip()
if not domain: abort(400)
reason=request.values.get("reason", "").strip()
reason=request.values.get("reason").strip()
d = g.db.query(BannedDomain).filter_by(domain=domain).one_or_none()
if d:

View File

@ -140,7 +140,7 @@
{% endif %}
{% if c.active_flags(v) %}<a class="btn btn-primary" style="padding:1px 5px; font-size:10px"role="button" onclick="document.getElementById('flaggers-{{c.id}}').classList.toggle('d-none')">{{c.active_flags(v)}} Report{{ help.plural(c.active_flags(v)) }}</a>{% endif %}
{% if c.over_18 %}<span class="badge badge-danger text-small-extra mr-1">+18</span>{% endif %}
{% if v and v.admin_level > 1 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.shadowbanned}}"></i>{% endif %}
{% if v and v.admin_level > 1 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.shadowbanned}} for "{{c.author.ban_reason}}"'></i>{% endif %}
{% if c.stickied %}
<i id='pinned-{{c.id}}'class="fas fa-thumbtack fa-rotate--45 text-admin" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Pinned by @{{c.stickied}}" {% if c.stickied_utc %}onmouseover="pinned_timestamp('pinned-{{c.id}}')" data-timestamp={{c.stickied_utc}} {% endif %}></i>
{% endif %}

View File

@ -9,6 +9,7 @@
<th>#</th>
<th>Name</th>
<th>Shadowbanned by</th>
<th>Shadowban reason</th>
</tr>
</thead>
{% for user in users %}
@ -16,6 +17,7 @@
<td>{{loop.index}}</td>
<td>{% include "user_in_table.html" %}</td>
<td>{{user.shadowbanned}}</td>
<td>{{user.ban_reason}}</td>
</tr>
{% endfor %}
</table>

View File

@ -640,7 +640,7 @@
<i class="{{a.class_list}} px-1" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{a.title}} Award given by @{{a.user.username}}"></i>
{% endfor %}
{% if v and v.admin_level > 1 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.shadowbanned}}"></i>{% endif %}
{% if v and v.admin_level > 1 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.shadowbanned}} for "{{p.author.ban_reason}}"'></i>{% endif %}
{% if p.stickied %}
<i id='pinned-{{p.id}}' class="fas fa-thumbtack fa-rotate--45 text-admin" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Pinned by @{{p.stickied}}" {% if p.stickied_utc %}onmouseover="pinned_timestamp('pinned-{{p.id}}')" data-timestamp={{p.stickied_utc}} {% endif %}></i>

View File

@ -134,7 +134,7 @@
{% endfor %}
{% if v and v.admin_level > 1 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.shadowbanned}}"></i>
<i class="fas fa-user-times text-admin" data-bs-toggle="tooltip" data-bs-placement="bottom" title='Shadowbanned by @{{p.author.shadowbanned}} for "{{p.author.ban_reason}}"'></i>
{% endif %}
{% if p.stickied %}

View File

@ -58,7 +58,11 @@
{% endif %}
{% endif %}
{% if v and v.admin_level >= 2 and u.shadowbanned %}
<h5 class="text-primary" id="profile--shadowbanned">SHADOWBANNED USER</h5>
<h5 class="text-primary" id="profile--shadowbanned">SHADOWBANNED USER
{% if u.ban_reason %}:
{{u.ban_reason | safe}}
{% endif %}
</h5>
{% endif %}
<div class="d-flex align-items-center mt-1 mb-2">
<h1 class="font-weight-bolder h3 my-0 mr-2" id="profile--name" style="color: #{{u.name_color}}"><span {% if u.patron %}class="patron" style="background-color:#{{u.name_color}}"{% endif %}>{{u.username}}</span></h1>
@ -289,6 +293,7 @@
</div>
<pre></pre>
<pre></pre>
{% if u.is_suspended %}
<form action="/unban_user/{{u.id}}" method="post" action="">
<input type="hidden" name="formkey" value="{{v.formkey}}">
@ -299,9 +304,9 @@
<form action="/ban_user/{{u.id}}" method="post" action="">
<input type="hidden" name="formkey" value="{{v.formkey}}">
<input type="hidden" name="redir" value="true">
<input autocomplete="off" style="font-size:11px" type="text" class="form-control" maxlength="256" name="reason" placeholder="Ban Reason" oninput="document.getElementById('user-ban-submit').disabled=false">
<input autocomplete="off" style="font-size:11px" type="text" class="form-control" maxlength="256" name="reason" placeholder="Ban Reason" oninput="document.getElementById('user-ban-submit').disabled=false" required>
<input autocomplete="off" style="font-size:11px" type="number" step="any" class="form-control" name="days" placeholder="Days (blank = permanent)">
<div class="custom-control custom-checkbox">
<div class="custom-control custom-checkbox mb-1">
<input autocomplete="off" type="checkbox" id="alts-2-desktop" class="custom-control-input" name="alts" value="1">
<label class="custom-control-label" for="alts-2-desktop">Include alts</label>
</div>
@ -309,27 +314,43 @@
</form>
{% endif %}
<pre></pre>
<pre></pre>
{% if u.shadowbanned %}
<form action="/unshadowban/{{u.id}}" method="post" action="">
<input type="hidden" name="formkey" value="{{v.formkey}}">
<input type="submit" onclick="disable(this)" class="btn btn-success" value="Unshadowban user">
</form>
{% else %}
<form action="/shadowban/{{u.id}}" method="post" action="">
<input type="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" oninput="document.getElementById('user-shadowban-submit').disabled=false" required>
<div class="custom-control custom-checkbox mb-1">
<input autocomplete="off" type="checkbox" id="shadowban-alts-2-desktop" class="custom-control-input" name="alts" value="1">
<label class="custom-control-label" for="shadowban-alts-2-desktop">Include alts</label>
</div>
<input autocomplete="off" id="user-shadowban-submit" type="submit" onclick="disable(this)" class="btn btn-danger" value="Shadowban user" disabled>
</form>
{% endif %}
<pre></pre>
<pre></pre>
<form id="agendaposter1" class="{% if u.agendaposter %}d-none{% endif %}" action="/agendaposter/{{u.id}}" method="post">
<input type="hidden" name="formkey", value="{{v.formkey}}">
<input autocomplete="off" type="number" step="any" name="days" class="form-control" placeholder="Days (0 or blank = permanent)">
<input type="submit" onclick="disable(this)" class="btn btn-danger" value="Lock Chud Theme">
</form>
<pre></pre>
<a id="unagendaposter" class="{% if not u.agendaposter %}d-none{% endif %} btn btn-success" role="button" onclick="post_toast(this,'/unagendaposter/{{u.id}}','agendaposter1','unagendaposter','d-none')">Disable Chud Theme</a>
<pre></pre>
<a id="shadowban" class="{% if u.shadowbanned %}d-none{% endif %} btn btn-danger" role="button" onclick="post_toast(this,'/shadowban/{{u.id}}','shadowban','unshadowban','d-none')">Shadowban</a>
<a id="unshadowban" class="{% if not u.shadowbanned %}d-none{% endif %} btn btn-success" role="button" onclick="post_toast(this,'/unshadowban/{{u.id}}','shadowban','unshadowban','d-none')">Unshadowban</a>
<a id="mute-user" class="{% if u.is_muted %}d-none{% endif %} btn btn-danger" role="button" onclick="post_toast(this,'/mute_user/{{u.id}}/1','mute-user','unmute-user','d-none')">Mute</a>
<a id="unmute-user" class="{% if not u.is_muted %}d-none{% endif %} btn btn-success" role="button" onclick="post_toast(this,'/mute_user/{{u.id}}/0','mute-user','unmute-user','d-none')">Unmute</a>
<pre></pre>
<pre></pre>
<form action="/admin/unnuke_user" method="post">
<input type="hidden" name="formkey", value="{{v.formkey}}">
@ -420,6 +441,10 @@
{% if u.unban_utc %}<h5 class="text-primary" id="profile-mobile--unban">{{u.unban_string}}</h5>{% endif %}
{% endif %}
{% if u.shadowbanned %}
<h5 class="text-primary" id="profile-mobile--banned">SHADOWBANNED USER{% if u.ban_reason %}: {{u.ban_reason | safe}}{% endif %}</h5>
{% endif %}
<h1 class="h5 d-inline-block" id="profile-mobile--name" style="color: #{{u.name_color}}"><span {% if u.patron %}class="patron" style="background-color:#{{u.name_color}}"{% endif %}>{{u.username}}</span></h1>
{% if u.username != u.original_username %}
@ -637,6 +662,7 @@
</div>
<pre></pre>
<pre></pre>
{% if u.is_suspended %}
<form action="/unban_user/{{u.id}}" method="post">
<input type="hidden" name="formkey", value="{{v.formkey}}">
@ -647,39 +673,52 @@
<form action="/ban_user/{{u.id}}" method="post">
<input type="hidden" name="formkey" value="{{v.formkey}}">
<input type="hidden" name="redir" value="true">
<input autocomplete="off" style="font-size:11px" type="text" class="form-control" maxlength="256" name="reason" placeholder="Ban Reason" oninput="document.getElementById('user-ban-submit2').disabled=false">
<input autocomplete="off" style="font-size:11px" type="text" class="form-control" maxlength="256" name="reason" placeholder="Ban Reason" oninput="document.getElementById('user-ban-submit2').disabled=false" required>
<input autocomplete="off" style="font-size:11px" type="number" step="any" class="form-control" name="days" placeholder="Days (blank = permanent)">
<br >
<div class="custom-control custom-checkbox">
<div class="custom-control custom-checkbox mb-1">
<input autocomplete="off" type="checkbox" id="alts-2-mobile" class="custom-control-input" name="alts" value="1">
<label class="custom-control-label" for="alts-2-mobile">Include alts</label>
</div>
<br >
<input autocomplete="off" id="user-ban-submit2" type="submit" onclick="disable(this)" class="btn btn-danger" value="Ban user" disabled>
</form>
{% endif %}
<pre></pre>
<pre></pre>
{% if u.shadowbanned %}
<form action="/unshadowban/{{u.id}}" method="post">
<input type="hidden" name="formkey", value="{{v.formkey}}">
<input type="submit" onclick="disable(this)" class="btn btn-success" value="Unshadowban user">
</form>
{% else %}
<form action="/shadowban/{{u.id}}" method="post">
<input type="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" oninput="document.getElementById('user-shadowban-submit2').disabled=false" required>
<div class="custom-control custom-checkbox mb-1">
<input autocomplete="off" type="checkbox" id="shadowban-alts-2-mobile" class="custom-control-input" name="alts" value="1">
<label class="custom-control-label" for="shadowban-alts-2-mobile">Include alts</label>
</div>
<input autocomplete="off" id="user-shadowban-submit2" type="submit" onclick="disable(this)" class="btn btn-danger" value="Shadowban user" disabled>
</form>
{% endif %}
<pre></pre>
<pre></pre>
<form id="agendaposter2" class="{% if u.agendaposter %}d-none{% endif %}" action="/agendaposter/{{u.id}}" method="post">
<input type="hidden" name="formkey", value="{{v.formkey}}">
<input autocomplete="off" type="number" step="any" name="days" class="form-control" placeholder="Days (0 or blank = permanent)">
<input type="submit" onclick="disable(this)" class="btn btn-danger" value="Lock Chud Theme">
</form>
<pre></pre>
<a id="unagendaposter2" class="{% if not u.agendaposter %}d-none{% endif %} btn btn-success" role="button" onclick="post_toast(this,'/unagendaposter/{{u.id}}','agendaposter2','unagendaposter2','d-none')">Disable Chud Theme</a>
<pre></pre>
<a id="shadowban2" class="{% if u.shadowbanned %}d-none{% endif %} btn btn-danger" role="button" onclick="post_toast(this,'/shadowban/{{u.id}}','shadowban2','unshadowban2','d-none')">Shadowban</a>
<a id="unshadowban2" class="{% if not u.shadowbanned %}d-none{% endif %} btn btn-success" role="button" onclick="post_toast(this,'/unshadowban/{{u.id}}','shadowban2','unshadowban2','d-none')">Unshadowban</a>
<a id="mute-user2" class="{% if u.is_muted %}d-none{% endif %} btn btn-danger" role="button" onclick="post_toast(this,'/mute_user/{{u.id}}/1','mute-user2','unmute-user2','d-none')">Mute</a>
<a id="unmute-user2" class="{% if not u.is_muted %}d-none{% endif %} btn btn-success" role="button" onclick="post_toast(this,'/mute_user/{{u.id}}/0','mute-user2','unmute-user2','d-none')">Unmute</a>
<pre></pre>
<pre></pre>
<form action="/admin/unnuke_user" method="post">
<input type="hidden" name="formkey", value="{{v.formkey}}">