fix 500 error

pull/225/head
Aevann 2024-03-10 16:36:14 +02:00
parent aa14d0e6d9
commit c54b48b3d4
2 changed files with 11 additions and 23 deletions

View File

@ -64,6 +64,7 @@ def private_chat(v, chat_id):
abort(403, "You're not a member of this chat!")
displayed_messages = g.db.query(ChatMessage).filter_by(chat_id=chat.id).limit(250).all()
displayed_messages = {m.id: m for m in displayed_messages}
notifs_msgs = g.db.query(ChatNotification, ChatMessage).join(ChatNotification.chat_message).filter(
ChatNotification.user_id == v.id,

View File

@ -351,30 +351,17 @@
{% macro chat_window(vlink)%}
<div id="shrink">
<div id="chat-window" class="container p-0">
{% if request.path == '/chat' %}
{% for id, m in messages.items()|list %}
{% set same = loop.index > 1 and m.user_id == messages_list[loop.index-2][1].user_id %}
{% if not same %}
{% if loop.index > 1 %}
</div>
{% endif %}
{{chat_group_template(id, m)}}
{% set messages_list = messages.items()|list %}
{% for id, m in messages_list %}
{% set same = loop.index > 1 and m.user_id == messages_list[loop.index-2][1].user_id %}
{% if not same %}
{% if loop.index > 1 %}
</div>
{% endif %}
{{chat_line_template(id, m, vlink)}}
{% endfor %}
{% else %}
{% for m in messages %}
{% set id = m.id %}
{% set same = loop.index > 1 and m.user_id == messages[loop.index-2].user_id %}
{% if not same %}
{% if loop.index > 1 %}
</div>
{% endif %}
{{chat_group_template(id, m)}}
{% endif %}
{{chat_line_template(id, m, vlink)}}
{% endfor %}
{% endif %}
{{chat_group_template(id, m)}}
{% endif %}
{{chat_line_template(id, m, vlink)}}
{% endfor %}
</div>
</div>