forked from rDrama/rDrama
linkfy chat messages in modlog under siege
parent
5ffabf632c
commit
7936979526
|
@ -94,3 +94,8 @@ class ChatMessage(Base):
|
||||||
@lazy
|
@lazy
|
||||||
def pride_username(self):
|
def pride_username(self):
|
||||||
return self.user.pride_username(None)
|
return self.user.pride_username(None)
|
||||||
|
|
||||||
|
@property
|
||||||
|
@lazy
|
||||||
|
def permalink(self):
|
||||||
|
return f"{SITE_FULL}/chat/{self.chat_id}#{self.id}"
|
||||||
|
|
|
@ -547,10 +547,8 @@ def execute_under_siege(v, target, body, kind):
|
||||||
reason = f'report on <a href="{target.permalink}">post</a>'
|
reason = f'report on <a href="{target.permalink}">post</a>'
|
||||||
else:
|
else:
|
||||||
reason = f'report on <a href="{target.permalink}">comment</a>'
|
reason = f'report on <a href="{target.permalink}">comment</a>'
|
||||||
elif hasattr(target, 'permalink'):
|
|
||||||
reason = f'<a href="{target.permalink}">{kind}</a>'
|
|
||||||
else:
|
else:
|
||||||
reason = kind
|
reason = f'<a href="{target.permalink}">{kind}</a>'
|
||||||
|
|
||||||
minutes = math.ceil(v.age / 60)
|
minutes = math.ceil(v.age / 60)
|
||||||
time_taken = f'{minutes} minute'
|
time_taken = f'{minutes} minute'
|
||||||
|
|
|
@ -106,9 +106,6 @@ def speak(data, v):
|
||||||
if isinstance(text_html , tuple): return ''
|
if isinstance(text_html , tuple): return ''
|
||||||
if len(text_html) > 5000: return ''
|
if len(text_html) > 5000: return ''
|
||||||
|
|
||||||
execute_blackjack(v, None, text, "chat")
|
|
||||||
execute_under_siege(v, None, text, "chat")
|
|
||||||
|
|
||||||
quotes = data['quotes']
|
quotes = data['quotes']
|
||||||
if quotes: quotes = int(quotes)
|
if quotes: quotes = int(quotes)
|
||||||
else: quotes = None
|
else: quotes = None
|
||||||
|
@ -125,6 +122,9 @@ def speak(data, v):
|
||||||
g.db.add(chat_message)
|
g.db.add(chat_message)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
||||||
|
execute_blackjack(v, chat_message, text, "chat")
|
||||||
|
execute_under_siege(v, chat_message, text, "chat")
|
||||||
|
|
||||||
if v.id == chat.owner_id:
|
if v.id == chat.owner_id:
|
||||||
for i in chat_adding_regex.finditer(text):
|
for i in chat_adding_regex.finditer(text):
|
||||||
user = get_user(i.group(1), graceful=True, attributes=[User.id])
|
user = get_user(i.group(1), graceful=True, attributes=[User.id])
|
||||||
|
|
|
@ -75,7 +75,12 @@ def chat(v, chat_id):
|
||||||
if v.admin_level < PERMS['VIEW_CHATS'] and not membership:
|
if v.admin_level < PERMS['VIEW_CHATS'] and not membership:
|
||||||
abort(403, "You're not a member of this chat!")
|
abort(403, "You're not a member of this chat!")
|
||||||
|
|
||||||
displayed_messages = reversed(g.db.query(ChatMessage).join(ChatMessage.user).filter(or_(User.id == v.id, User.shadowbanned == None)).options(joinedload(ChatMessage.quoted_message)).filter(ChatMessage.chat_id == chat.id).order_by(ChatMessage.id.desc()).limit(250).all())
|
displayed_messages = g.db.query(ChatMessage).options(joinedload(ChatMessage.quoted_message)).filter(ChatMessage.chat_id == chat.id)
|
||||||
|
|
||||||
|
if v.admin_level < PERMS['USER_SHADOWBAN']:
|
||||||
|
displayed_messages = displayed_messages.join(ChatMessage.user).filter(or_(User.id == v.id, User.shadowbanned == None))
|
||||||
|
|
||||||
|
displayed_messages = reversed(displayed_messages.order_by(ChatMessage.id.desc()).limit(250).all())
|
||||||
displayed_messages = {m.id: m for m in displayed_messages}
|
displayed_messages = {m.id: m for m in displayed_messages}
|
||||||
|
|
||||||
if chat.id == 1:
|
if chat.id == 1:
|
||||||
|
|
|
@ -272,6 +272,12 @@
|
||||||
|
|
||||||
{% macro chat_group_template(id, m) %}
|
{% macro chat_group_template(id, m) %}
|
||||||
<div class="chat-group">
|
<div class="chat-group">
|
||||||
|
{% if m %}
|
||||||
|
{% with user = m.user %}
|
||||||
|
{%- include 'admin/shadowbanned_tooltip.html' -%}
|
||||||
|
{% endwith %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<a class="font-weight-bold userlink" target="_blank" {% if m %}style="color:#{{m.namecolor}}" href="/@{{m.username}}" {% endif %}>
|
<a class="font-weight-bold userlink" target="_blank" {% if m %}style="color:#{{m.namecolor}}" href="/@{{m.username}}" {% endif %}>
|
||||||
<div class="avatar profile-pic-20-wrapper">
|
<div class="avatar profile-pic-20-wrapper">
|
||||||
<img loading="lazy" class="avatar-pic pp20 mr-1" {% if m %}src="/pp/{{m.user_id}}"{% endif %}>
|
<img loading="lazy" class="avatar-pic pp20 mr-1" {% if m %}src="/pp/{{m.user_id}}"{% endif %}>
|
||||||
|
|
Loading…
Reference in New Issue