forked from rDrama/rDrama
1
0
Fork 0

underage ban age

master
Aevann 2024-05-16 23:17:52 +03:00
parent 0760ff2482
commit 3ac74a77fa
9 changed files with 56 additions and 17 deletions

View File

@ -4402,11 +4402,11 @@ small, .small {
margin-top: 2rem; margin-top: 2rem;
padding-left: 12px; padding-left: 12px;
} }
#notifications .comment, #userpage .comment { #notifications .comment, #userpage .comment, #contact .comment {
margin-top: 0.5rem; margin-top: 0.5rem;
margin-bottom: 1rem; margin-bottom: 1rem;
} }
#notifications .comment:last-child, #userpage .comment:last-child { #notifications .comment:last-child, #userpage .comment:last-child, #contact .comment:last-child {
margin-bottom: 0; margin-bottom: 0;
} }
.comment .comment-body { .comment .comment-body {

View File

@ -464,6 +464,7 @@ WERKZEUG_ERROR_DESCRIPTIONS = {
403: "You don't have the permission to access the requested resource. It is either read-protected or not readable by the server.", 403: "You don't have the permission to access the requested resource. It is either read-protected or not readable by the server.",
404: "The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.", 404: "The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.",
405: "The method is not allowed for the requested URL.", 405: "The method is not allowed for the requested URL.",
406: "The resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request.",
409: "A conflict happened while processing the request. The resource might have been modified while the request was being processed.", 409: "A conflict happened while processing the request. The resource might have been modified while the request was being processed.",
410: "The requested URL is no longer available on this server and there is no forwarding address. If you followed a link from a foreign page, please contact the author of this page.", 410: "The requested URL is no longer available on this server and there is no forwarding address. If you followed a link from a foreign page, please contact the author of this page.",
413: "The data value transmitted exceeds the capacity limit.", 413: "The data value transmitted exceeds the capacity limit.",
@ -481,6 +482,7 @@ ERROR_TITLES = {
403: "Forbidden🙅", 403: "Forbidden🙅",
404: "Not Found - where did it go?", 404: "Not Found - where did it go?",
405: "Method Not Allowed, BAD.", 405: "Method Not Allowed, BAD.",
406: "THIS IS AN 18+ WEBSITE",
409: "Cumflict", 409: "Cumflict",
410: "Gone... and Forgotten", 410: "Gone... and Forgotten",
413: "Gayload Too Large", 413: "Gayload Too Large",
@ -496,6 +498,7 @@ ERROR_MSGS = {
403: "YOU AREN'T WELCOME HERE GO AWAY", 403: "YOU AREN'T WELCOME HERE GO AWAY",
404: "Someone typed something wrong and it was probably you, please do better.", 404: "Someone typed something wrong and it was probably you, please do better.",
405: "idk how anyone gets this error but if you see this, remember to follow @carpathianflorist<br>the original error text here talked about internet gremlins and wtf", 405: "idk how anyone gets this error but if you see this, remember to follow @carpathianflorist<br>the original error text here talked about internet gremlins and wtf",
406: "You have been banned for being underage.<br>If this was in error, please contact the admins below.",
409: "There's a conflict between what you're trying to do and what you or someone else has done and because of that you can't do what you're trying to do. So maybe like... don't try and do that? Sorry not sorry", 409: "There's a conflict between what you're trying to do and what you or someone else has done and because of that you can't do what you're trying to do. So maybe like... don't try and do that? Sorry not sorry",
410: "You were too slow. The link FUCKING DIED. Request a new one and be more efficient.", 410: "You were too slow. The link FUCKING DIED. Request a new one and be more efficient.",
413: "That's a heckin' chonker of a file! Please make it smaller or maybe like upload it somewhere else idk<br>jc wrote this one hi jc!<br>- carp", 413: "That's a heckin' chonker of a file! Please make it smaller or maybe like upload it somewhere else idk<br>jc wrote this one hi jc!<br>- carp",
@ -511,6 +514,7 @@ ERROR_MARSEYS = {
403: "marseytroll", 403: "marseytroll",
404: "marseyconfused", 404: "marseyconfused",
405: "marseyretard", 405: "marseyretard",
406: "marseydisagree",
409: "marseynoyou", 409: "marseynoyou",
410: "marseyrave", 410: "marseyrave",
413: "marseychonker2", 413: "marseychonker2",

View File

@ -20,6 +20,7 @@ from files.__main__ import app, limiter
@app.errorhandler(403) @app.errorhandler(403)
@app.errorhandler(404) @app.errorhandler(404)
@app.errorhandler(405) @app.errorhandler(405)
@app.errorhandler(406)
@app.errorhandler(409) @app.errorhandler(409)
@app.errorhandler(410) @app.errorhandler(410)
@app.errorhandler(413) @app.errorhandler(413)

View File

@ -150,11 +150,7 @@ def notifications_chats(v):
return render_template("notifications.html", v=v, notifications=chats) return render_template("notifications.html", v=v, notifications=chats)
@app.get("/notifications/modmail") def modmail_listing(v):
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
@admin_level_required(PERMS['VIEW_MODMAIL'])
def notifications_modmail(v):
page = get_page() page = get_page()
sq = g.db.query(Comment.top_comment_id, Comment.created_utc).distinct(Comment.top_comment_id).filter_by(sentto=MODMAIL_ID).order_by(Comment.top_comment_id, Comment.created_utc.desc()).subquery() sq = g.db.query(Comment.top_comment_id, Comment.created_utc).distinct(Comment.top_comment_id).filter_by(sentto=MODMAIL_ID).order_by(Comment.top_comment_id, Comment.created_utc.desc()).subquery()
@ -174,6 +170,15 @@ def notifications_modmail(v):
v.last_viewed_modmail_notifs = int(time.time()) v.last_viewed_modmail_notifs = int(time.time())
g.db.add(v) g.db.add(v)
return listing, total, page
@app.get("/notifications/modmail")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
@admin_level_required(PERMS['VIEW_MODMAIL'])
def notifications_modmail(v):
listing, total, page = modmail_listing(v)
if v.client: return {"data":[x.json for x in listing]} if v.client: return {"data":[x.json for x in listing]}
return render_template("notifications.html", return render_template("notifications.html",

View File

@ -15,6 +15,7 @@ from files.helpers.alerts import *
from files.helpers.config.const import * from files.helpers.config.const import *
from files.helpers.config.modaction_types import * from files.helpers.config.modaction_types import *
from files.routes.wrappers import * from files.routes.wrappers import *
from files.routes.notifications import modmail_listing
from files.__main__ import app, cache, limiter from files.__main__ import app, cache, limiter
@ -280,7 +281,15 @@ def api(v):
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400) @limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@auth_desired @auth_desired
def contact(v): def contact(v):
return render_template("contact.html", v=v) listing, total, page = modmail_listing(v)
return render_template("contact.html",
v=v,
listing=listing,
total=total,
page=page,
standalone=True,
render_replies=True,
)
@app.post("/contact") @app.post("/contact")
@limiter.limit('1/second', scope=rpath) @limiter.limit('1/second', scope=rpath)

View File

@ -87,6 +87,9 @@ def get_logged_in_user():
else: else:
session.pop("lo_user") session.pop("lo_user")
if request.path != '/contact' and v and v.is_suspended and 'underage' in v.ban_reason.lower():
abort(406)
if request.method != "GET" and get_setting('read_only_mode') and not (v and v.admin_level >= PERMS['BYPASS_SITE_READ_ONLY_MODE']): if request.method != "GET" and get_setting('read_only_mode') and not (v and v.admin_level >= PERMS['BYPASS_SITE_READ_ONLY_MODE']):
abort(403, "Site is in read-only mode right now. It will be back shortly!") abort(403, "Site is in read-only mode right now. It will be back shortly!")

View File

@ -36,7 +36,7 @@
</div> </div>
{% if render_replies %} {% if render_replies %}
<div id="replies-of-{{c.fullname}}"> <div id="replies-of-{{c.fullname}}">
{% if level<9 or request.path.startswith('/notifications') %} {% if level<9 or request.path.startswith('/notifications') or request.path == '/contact' %}
{% for reply in replies %} {% for reply in replies %}
{{single_comment(reply, level=level+1)}} {{single_comment(reply, level=level+1)}}
{% endfor %} {% endfor %}
@ -61,7 +61,7 @@
{% endif %} {% endif %}
{% if standalone and level == 1 %} {% if standalone and level == 1 %}
<div id="post-info-{{c.id}}" class="{% if c.admin_note %}admin-note{% endif %} post-info mb-1 mr-2 {% if request.path.startswith('/notifications') %}mt-5{% elif request.path == '/search/messages' %}mt-6{% else %}mt-3{% endif %}"> <div id="post-info-{{c.id}}" class="{% if c.admin_note %}admin-note{% endif %} post-info mb-1 mr-2 {% if request.path.startswith('/notifications') or request.path == '/contact' %}mt-5{% elif request.path == '/search/messages' %}mt-6{% else %}mt-3{% endif %}">
{% if c.parent_post and c.post.nsfw %} {% if c.parent_post and c.post.nsfw %}
<span class="badge badge-danger text-small-extra mr-1">NSFW</span> <span class="badge badge-danger text-small-extra mr-1">NSFW</span>
{% endif %} {% endif %}
@ -535,7 +535,7 @@
{% if render_replies %} {% if render_replies %}
<div id="replies-of-{{c.fullname}}"> <div id="replies-of-{{c.fullname}}">
{% if request.path.startswith('/notifications') and replies|length > 8 %} {% if (request.path.startswith('/notifications') or request.path == '/contact') and replies|length > 8 %}
{% for reply in replies %} {% for reply in replies %}
{% if reply.parent_post %} {% if reply.parent_post %}
{% set collapse = reply.collapse %} {% set collapse = reply.collapse %}
@ -544,7 +544,7 @@
{% endif %} {% endif %}
{{single_comment(reply, level=level+1, collapse=collapse)}} {{single_comment(reply, level=level+1, collapse=collapse)}}
{% endfor %} {% endfor %}
{% elif request.path.startswith('/notifications') or level < 9 %} {% elif (request.path.startswith('/notifications') or request.path == '/contact') or level < 9 %}
{% for reply in replies %} {% for reply in replies %}
{{single_comment(reply, level=level+1)}} {{single_comment(reply, level=level+1)}}
{% endfor %} {% endfor %}
@ -554,7 +554,7 @@
{% endif %} {% endif %}
</div> </div>
{% if (request.path.startswith('/notification') or request.path == '/search/messages') and c.level == 1 and c.sentto and not c.parent_post and c.author_id != AUTOJANNY_ID %} {% if (request.path.startswith('/notification') or request.path in ('/search/messages', '/contact')) and c.level == 1 and c.sentto and not c.parent_post and c.author_id != AUTOJANNY_ID %}
<button id="toggle-reply-{{c.fullname}}" type="button" class="btn btn-primary nobackground mt-2" data-nonce="{{g.nonce}}" data-onclick="toggleReplyBox(this, 'reply-to-{{c.fullname}}')">Reply</button> <button id="toggle-reply-{{c.fullname}}" type="button" class="btn btn-primary nobackground mt-2" data-nonce="{{g.nonce}}" data-onclick="toggleReplyBox(this, 'reply-to-{{c.fullname}}')">Reply</button>
{% if c.sentto == MODMAIL_ID and v and v.id != c.author_id and v.admin_level >= PERMS['USER_BAN'] %} {% if c.sentto == MODMAIL_ID and v and v.id != c.author_id and v.admin_level >= PERMS['USER_BAN'] %}

View File

@ -1,8 +1,8 @@
{% extends "default.html" %} {% extends "default.html" %}
{% block pagetitle %}Contact{% endblock %} {% block pagetitle %}Contact{% endblock %}
{% block content %} {% block content %}
<div class="px-2 px-md-0"> <div id="contact" class="px-2 px-md-0">
<h1 class="text-lg-sm">Contact {{SITE_NAME}} Admins</h1> <h3 class="text-lg-sm">Contact {{SITE_NAME}} Admins</h3>
{% if v %} {% if v %}
<form id="contactform" action="/contact" method="post" enctype="multipart/form-data" data-nonce="{{g.nonce}}" data-onsubmit="contact(this)"> <form id="contactform" action="/contact" method="post" enctype="multipart/form-data" data-nonce="{{g.nonce}}" data-onsubmit="contact(this)">
<label for="input-message" class="mt-3">Your message</label> <label for="input-message" class="mt-3">Your message</label>
@ -25,7 +25,20 @@
{% else %} {% else %}
<h4>by email: {{EMAIL}}</h4> <h4>by email: {{EMAIL}}</h4>
{% endif %} {% endif %}
{% if listing %}
<h3 class="text-lg-sm mt-5 pb-0 mb-0" style="margin-bottom:-14px !important">Previous Contacts</h3>
{% with comments=listing %}
{% include "comments.html" %}
{% endwith %}
{% endif %}
</div> </div>
<script defer src="{{'js/contact.js' | asset}}"></script> <script defer src="{{'js/contact.js' | asset}}"></script>
{% endblock %} {% endblock %}
{% block pagenav %}
{% if listing %}
{{macros.pagination()}}
{% endif %}
{% endblock %}

View File

@ -8,12 +8,16 @@
{% if img -%} {% if img -%}
<img alt=":#{{img}}:" loading="lazy" src="{{SITE_FULL_IMAGES}}/e/{{img}}.webp"> <img alt=":#{{img}}:" loading="lazy" src="{{SITE_FULL_IMAGES}}/e/{{img}}.webp">
{%- endif %} {%- endif %}
<h5 class="mt-1">{{title}}</h5> <h5 class="mt-2">{{title}}</h5>
<p class="text-muted error-description">{{msg|safe}}</p> <p class="text-muted error-description">{{msg|safe}}</p>
{% if details -%} {% if details -%}
<blockquote class="error-details mb-4 py-2">{{details|safe}}</blockquote> <blockquote class="error-details mb-4 py-2">{{details|safe}}</blockquote>
{%- endif %} {%- endif %}
<div><a href="/" class="btn btn-primary mt-3">Go to frontpage</a></div> {% if title == 'THIS IS AN 18+ WEBSITE' %}
<div><a href="/contact" class="btn btn-primary mt-1">Contact Admins</a></div>
{% else %}
<div><a href="/" class="btn btn-primary mt-3">Go to frontpage</a></div>
{% endif %}
</div> </div>
</div> </div>
</div> </div>