fix request referrer breaking

master
Aevann 2024-11-11 19:41:56 +02:00
parent 220b2ba1ff
commit ab016407be
4 changed files with 7 additions and 6 deletions

View File

@ -108,7 +108,7 @@ socket.on('speak', function(json) {
document.getElementsByClassName('time')[0].innerHTML = formatHourMinute(new Date(json.created_utc*1000))
document.getElementsByClassName('link')[0].href = `/chat/${chat_id}/${json.id}#${json.id}`
document.getElementsByClassName('link')[0].href = `/chat/${chat_id}?m=${json.id}#${json.id}`
document.getElementsByClassName('link')[0].innerHTML = `#${json.id}`
}
@ -234,7 +234,7 @@ ta.addEventListener("keydown", function(e) {
socket.on('online', function(data) {
const online_li = data[0]
if (!location.pathname.startsWith('/chat/1')) {
if (chat_id != 1) {
for (const marker of document.getElementsByClassName('online-marker')) {
marker.classList.add('d-none')
}

View File

@ -63,11 +63,10 @@ def chat_user(v, username):
@app.get("/chat/<int:chat_id>")
@app.get("/chat/<int:chat_id>/<int:message_id>")
@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)
@auth_required
def chat(v, chat_id, message_id=None):
def chat(v, chat_id):
chat = g.db.get(Chat, chat_id)
if not chat:
stop(404, "Chat not found!")
@ -90,7 +89,9 @@ def chat(v, chat_id, message_id=None):
if v.admin_level < PERMS['USER_SHADOWBAN']:
displayed_messages = displayed_messages.join(ChatMessage.user).filter(or_(User.id == v.id, User.shadowbanned == None))
message_id = request.values.get('m')
if message_id:
message_id = int(message_id)
start = message_id - 125
finish = message_id + 125
displayed_messages = displayed_messages.filter(ChatMessage.id > start, ChatMessage.id < finish)

View File

@ -508,7 +508,7 @@
</li>
{% endif %}
<li class="mt-3">
{% if request.path.startswith('/chat/1') %}
{% if request.path == '/chat/1' %}
{% if SITE_NAME == 'WPD' %}
<h5 class="ml-2">Chat Rules</h5>
<ul class="ml-2">

View File

@ -303,7 +303,7 @@
{%- endif -%}
</span>
<a class="text-black link ml-1 text-center" {% if m %}href="/chat/{{chat.id}}/{{m.id}}#{{m.id}}"{% endif %}>
<a class="text-black link ml-1 text-center" {% if m %}href="/chat/{{chat.id}}?m={{m.id}}#{{m.id}}"{% endif %}>
{%- if m -%}
#{{m.id}}
{% endif %}