make a UI for /admin/dm_images
parent
45dfb9cb07
commit
c45cd0fde8
|
@ -6673,3 +6673,8 @@ body {
|
|||
.modal, body, nav {
|
||||
padding-right: 0 !important;
|
||||
}
|
||||
|
||||
.dm_img[alt^="![]("] {
|
||||
width: 200px;
|
||||
max-height: 100vh !important;
|
||||
}
|
||||
|
|
|
@ -229,7 +229,7 @@ def process_image(filename:str, v, resize=0, trim=False, uploader_id:Optional[in
|
|||
return filename
|
||||
|
||||
|
||||
def process_dm_images(v):
|
||||
def process_dm_images(v, user):
|
||||
if not request.files.get("file") or g.is_tor or not get_setting("dm_images"):
|
||||
return ''
|
||||
|
||||
|
@ -265,7 +265,8 @@ def process_dm_images(v):
|
|||
|
||||
body += f'\n\n{url}\n\n'
|
||||
|
||||
with open(f"{LOG_DIRECTORY}/dm_images.log", "a+", encoding="utf-8") as f:
|
||||
f.write(body.strip() + '\n')
|
||||
if body:
|
||||
with open(f"{LOG_DIRECTORY}/dm_images.log", "a+", encoding="utf-8") as f:
|
||||
f.write(f'{body.strip()}, {v.username}, {v.id}, {user.username}, {user.id}\n')
|
||||
|
||||
return body
|
||||
|
|
|
@ -44,7 +44,11 @@ def loggedout_list(v):
|
|||
@admin_level_required(PERMS['VIEW_DM_IMAGES'])
|
||||
def dm_images(v):
|
||||
with open(f"{LOG_DIRECTORY}/dm_images.log", "r", encoding="utf-8") as f:
|
||||
return f.read()
|
||||
items=f.read().split("\n")[:-1]
|
||||
|
||||
items = [x.split(", ") for x in items]
|
||||
|
||||
return render_template("admin/dm_images.html", v=v, items=items)
|
||||
|
||||
@app.get('/admin/edit_rules')
|
||||
@limiter.limit(DEFAULT_RATELIMIT, key_func=get_ID)
|
||||
|
|
|
@ -493,7 +493,7 @@ def message2(v:User, username:str):
|
|||
|
||||
message = sanitize_raw_body(request.values.get("message"), False)
|
||||
|
||||
message += process_dm_images(v)
|
||||
message += process_dm_images(v, user)
|
||||
|
||||
if not message: abort(400, "Message is empty!")
|
||||
|
||||
|
@ -566,7 +566,7 @@ def messagereply(v:User):
|
|||
and hasattr(user, 'is_blocked') and user.is_blocked):
|
||||
abort(403, f"You're blocked by @{user.username}")
|
||||
|
||||
body += process_dm_images(v)
|
||||
body += process_dm_images(v, user)
|
||||
|
||||
body = body.strip()
|
||||
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
{% extends "default.html" %}
|
||||
{% block pagetitle %}DM Imagtes{% endblock %}
|
||||
{% block content %}
|
||||
<h2>DM Images</h2>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="table table-striped mb-5">
|
||||
<thead class="bg-primary text-white">
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Image</th>
|
||||
<th>Sender</th>
|
||||
<th>Sent To</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
{% for item in items %}
|
||||
<tr>
|
||||
<td>{{loop.index}}</td>
|
||||
<td>
|
||||
<a href="{{item[0]}}" target="_blank">
|
||||
<img alt="![]({{item[0]}})" src="{{item[0]}}" loading="lazy" class="dm_img">
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
{% if item[1] != "Unknown" %}
|
||||
<a href="/id/{{item[2]}}">
|
||||
<img loading="lazy" src="/pp/{{item[2]}}">
|
||||
@{{item[1]}}
|
||||
</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if item[1] != "Unknown" %}
|
||||
<a href="/id/{{item[4]}}">
|
||||
<img loading="lazy" src="/pp/{{item[4]}}">
|
||||
@{{item[3]}}
|
||||
</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
{% endblock %}
|
Loading…
Reference in New Issue