always display the text of quoted messages even if they're not visible

master
Aevann 2024-04-07 08:29:11 +02:00
parent e8d3bac7ca
commit 06782b1325
3 changed files with 8 additions and 8 deletions

View File

@ -66,6 +66,7 @@ class ChatMessage(Base):
created_utc = Column(Integer)
user = relationship("User")
quoted_message = relationship("ChatMessage", remote_side=[id])
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())

View File

@ -71,7 +71,7 @@ def chat(v, chat_id):
if v.admin_level < PERMS['VIEW_CHATS'] and not membership:
abort(403, "You're not a member of this chat!")
displayed_messages = reversed(g.db.query(ChatMessage).filter_by(chat_id=chat.id).order_by(ChatMessage.id.desc()).limit(250).all())
displayed_messages = reversed(g.db.query(ChatMessage).options(joinedload(ChatMessage.quoted_message)).filter_by(chat_id=chat.id).order_by(ChatMessage.id.desc()).limit(250).all())
displayed_messages = {m.id: m for m in displayed_messages}
if chat.id == 1:

View File

@ -284,8 +284,7 @@
{% endmacro %}
{% macro chat_line_template(id, m, vlink) %}
{% set quote_exists = m and m.quotes and messages.get(m.quotes) %}
{% set mentioned = m and vlink in m.text_html or (quote_exists and messages[m.quotes].user_id == v.id) %}
{% set mentioned = m and vlink in m.text_html or (m and m.quoted_message and m.quoted_message.user_id == v.id) %}
<div class="chat-line {% if mentioned %}chat-mention{% endif %}" {% if m %}id="{{id}}"{% endif %}>
<div class="d-flex align-items-center">
<div class="text-muted chat-line-content">
@ -293,16 +292,16 @@
<a class="QuotedMessageLink" {% if m and m.quotes %}href="#{{m.quotes}}"{% endif %}>
<i class="fas fa-reply"></i>
<span class="text-primary">@<span class="QuotedUser">
{%- if quote_exists -%}
{{messages[m.quotes].username}}
{%- if m and m.quoted_message -%}
{{m.quoted_message.username}}
{%- endif -%}
</span></span>:
<em class="QuotedMessage">
{%- if quote_exists -%}
{%- if m and m.quoted_message -%}
{%- if v.slurreplacer -%}
{{messages[m.quotes].text_censored}}
{{m.quoted_message.text_censored}}
{%- else -%}
{{messages[m.quotes].text}}
{{m.quoted_message.text}}
{%- endif -%}
{%- endif -%}
</em>