master
Aevann1 2022-02-01 01:10:24 +02:00
parent db0a881326
commit 26bfdd4f33
5 changed files with 25 additions and 31 deletions

View File

@ -87,3 +87,19 @@ def NOTIFY_USERS2(text, v):
if user and not v.any_block_exists(user): notify_users.add(user.id) if user and not v.any_block_exists(user): notify_users.add(user.id)
return notify_users return notify_users
def send_admin(id, body_html):
new_comment = Comment(author_id=id,
parent_submission=None,
level=1,
sentto=0,
body_html=body_html,
)
g.db.add(new_comment)
g.db.flush()
admins = g.db.query(User).filter(User.admin_level > 2).all()
for admin in admins:
notif = Notification(comment_id=new_comment.id, user_id=admin.id)
g.db.add(notif)

View File

@ -175,7 +175,7 @@ def club_ban(v, username):
@app.post("/@<username>/make_meme_admin") @app.post("/@<username>/make_meme_admin")
@limiter.limit("1/second;30/minute;200/hour;1000/day") @limiter.limit("1/second;30/minute;200/hour;1000/day")
@admin_level_required(2) @admin_level_required(3)
def make_meme_admin(v, username): def make_meme_admin(v, username):
if request.host == 'pcmemes.net' or (SITE_NAME == 'Drama' and v.admin_level > 2) or (request.host != 'rdrama.net' and request.host != 'pcmemes.net'): if request.host == 'pcmemes.net' or (SITE_NAME == 'Drama' and v.admin_level > 2) or (request.host != 'rdrama.net' and request.host != 'pcmemes.net'):
user = get_user(username) user = get_user(username)
@ -188,7 +188,7 @@ def make_meme_admin(v, username):
@app.post("/@<username>/remove_meme_admin") @app.post("/@<username>/remove_meme_admin")
@limiter.limit("1/second;30/minute;200/hour;1000/day") @limiter.limit("1/second;30/minute;200/hour;1000/day")
@admin_level_required(2) @admin_level_required(3)
def remove_meme_admin(v, username): def remove_meme_admin(v, username):
if request.host == 'pcmemes.net' or (SITE_NAME == 'Drama' and v.admin_level > 2) or (request.host != 'rdrama.net' and request.host != 'pcmemes.net'): if request.host == 'pcmemes.net' or (SITE_NAME == 'Drama' and v.admin_level > 2) or (request.host != 'rdrama.net' and request.host != 'pcmemes.net'):
user = get_user(username) user = get_user(username)
@ -387,7 +387,7 @@ def purge_cache(v):
@app.post("/admin/under_attack") @app.post("/admin/under_attack")
@admin_level_required(2) @admin_level_required(3)
def under_attack(v): def under_attack(v):
if environ.get('under_attack'): if environ.get('under_attack'):
environ["under_attack"] = "" environ["under_attack"] = ""
@ -1217,7 +1217,7 @@ def admin_dump_cache(v):
@app.get("/admin/banned_domains/") @app.get("/admin/banned_domains/")
@admin_level_required(2) @admin_level_required(3)
def admin_banned_domains(v): def admin_banned_domains(v):
banned_domains = g.db.query(BannedDomain).all() banned_domains = g.db.query(BannedDomain).all()
@ -1225,7 +1225,7 @@ def admin_banned_domains(v):
@app.post("/admin/banned_domains") @app.post("/admin/banned_domains")
@limiter.limit("1/second;30/minute;200/hour;1000/day") @limiter.limit("1/second;30/minute;200/hour;1000/day")
@admin_level_required(2) @admin_level_required(3)
def admin_toggle_ban_domain(v): def admin_toggle_ban_domain(v):
domain=request.values.get("domain", "").strip() domain=request.values.get("domain", "").strip()

View File

@ -295,19 +295,7 @@ def submit_contact(v):
body_html += f"<p>{url}</p>" body_html += f"<p>{url}</p>"
else: return {"error": "Image/Video files only"}, 400 else: return {"error": "Image/Video files only"}, 400
new_comment = Comment(author_id=v.id, send_admin(v.id, body_html)
parent_submission=None,
level=1,
sentto=0,
body_html=body_html,
)
g.db.add(new_comment)
g.db.flush()
admins = g.db.query(User).filter(User.admin_level > 2).all()
for admin in admins:
notif = Notification(comment_id=new_comment.id, user_id=admin.id)
g.db.add(notif)
g.db.commit() g.db.commit()
return render_template("contact.html", v=v, msg="Your message has been sent.") return render_template("contact.html", v=v, msg="Your message has been sent.")

View File

@ -457,7 +457,7 @@ def message2(v, username):
if v.admin_level <= 1 and hasattr(user, 'is_blocked') and user.is_blocked: if v.admin_level <= 1 and hasattr(user, 'is_blocked') and user.is_blocked:
return {"error": "This user is blocking you."}, 403 return {"error": "This user is blocking you."}, 403
if v.shadowbanned: return {"message": "Message sent!"} if v.shadowbanned and user.admin_level < 2: return {"message": "Message sent!"}
message = request.values.get("message", "").strip()[:10000].strip() message = request.values.get("message", "").strip()[:10000].strip()

View File

@ -12,16 +12,6 @@
<script src="/static/assets/js/new_comments_count.js?a=220"></script> <script src="/static/assets/js/new_comments_count.js?a=220"></script>
{% endif %} {% endif %}
<script>
function togglevideo(pid) {
let vid = document.getElementById(`video-${pid}`).classList
vid.toggle('d-none')
let vid2 = document.getElementById(`video2-${pid}`)
if (vid.contains('d-none')) vid2.pause()
else vid2.play()
}
</script>
<div style="display:none" id="popover"> <div style="display:none" id="popover">
<div class="popover-user-profile" role="tooltip"> <div class="popover-user-profile" role="tooltip">
<img loading="lazy" class="pop-banner w-100 h-64 object-cover"> <img loading="lazy" class="pop-banner w-100 h-64 object-cover">
@ -691,4 +681,4 @@
<script src="/static/assets/js/clipboard.js?a=220"></script> <script src="/static/assets/js/clipboard.js?a=220"></script>
<script src="/static/assets/js/comments+submission_listing.js?a=221"></script> <script src="/static/assets/js/comments+submission_listing.js?a=221"></script>
<script src="/static/assets/js/submission_listing.js?a=220"></script> <script src="/static/assets/js/submission_listing.js?a=221"></script>