make blocking affect chat too

pull/183/head
Aevann 2023-08-09 18:19:43 +03:00
parent c9abf14349
commit 028a92162b
3 changed files with 16 additions and 3 deletions

View File

@ -64,7 +64,13 @@ function flash(){
}
const blocked_user_ids = document.getElementById('blocked_user_ids').value.split(',')
socket.on('speak', function(json) {
if (blocked_user_ids.includes(json.user_id.toString())) {
return
}
let text
let text_html

View File

@ -55,10 +55,13 @@ def chat(v):
if not v.admin_level and TRUESCORE_CHAT_MINIMUM and v.truescore < TRUESCORE_CHAT_MINIMUM:
abort(403, f"Need at least {TRUESCORE_CHAT_MINIMUM} truescore for access to chat!")
orgy = get_orgy()
displayed_messages = {k: val for k, val in messages.items() if val["user_id"] not in v.userblocks}
if orgy:
return render_template("orgy.html", v=v, messages=messages, orgy = orgy, site = SITE)
return render_template("orgy.html", v=v, messages=displayed_messages, orgy=orgy, site=SITE)
else:
return render_template("chat.html", v=v, messages=messages)
return render_template("chat.html", v=v, messages=displayed_messages)
@app.get("/old_chat")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@ -67,7 +70,10 @@ def chat(v):
def old_chat(v):
if not v.admin_level and TRUESCORE_CHAT_MINIMUM and v.truescore < TRUESCORE_CHAT_MINIMUM:
abort(403, f"Need at least {TRUESCORE_CHAT_MINIMUM} truescore for access to chat!")
return render_template("chat.html", v=v, messages=messages)
displayed_messages = {k: val for k, val in messages.items() if val["user_id"] not in v.userblocks}
return render_template("chat.html", v=v, messages=displayed_messages)
@socketio.on('speak')
@is_not_banned_socketio

View File

@ -33,6 +33,7 @@
<input id="site_name" hidden value="{{SITE_NAME}}">
<input id="slurreplacer" hidden value="{{v.slurreplacer}}">
<input id="admin_level" hidden value="{{v.admin_level}}">
<input id="blocked_user_ids" hidden value="{{(v.userblocks|string)[1:-1]}}">
<script defer src="{{'js/vendor/socketio.js' | asset}}"></script>
<script defer src="{{'js/chat.js' | asset}}"></script>
<script defer src="{{'js/vendor/lozad.js' | asset}}"></script>