forked from rDrama/rDrama
Merge branch 'frost' into blitzen
commit
b198ee8272
|
@ -33,7 +33,7 @@ app.config['DATABASE_URL'] = environ.get("DATABASE_URL")
|
|||
app.config['SECRET_KEY'] = environ.get('MASTER_KEY')
|
||||
app.config["SERVER_NAME"] = environ.get("DOMAIN").strip()
|
||||
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 86400
|
||||
app.config["SESSION_COOKIE_NAME"] = "session_" + environ.get("DOMAIN")
|
||||
app.config["SESSION_COOKIE_NAME"] = f'session_{environ.get("DOMAIN")}'.strip().lower()
|
||||
app.config["VERSION"] = "1.0.0"
|
||||
app.config['MAX_CONTENT_LENGTH'] = 8 * 1024 * 1024
|
||||
app.config["SESSION_COOKIE_SECURE"] = bool(int(environ.get("FORCE_HTTPS", 1)))
|
||||
|
|
|
@ -6,31 +6,37 @@ from .markdown import *
|
|||
from .sanitize import *
|
||||
from .const import *
|
||||
|
||||
def send_repeatable_notification(uid, text, autojanny=False):
|
||||
def create_comment(text, autojanny=False):
|
||||
if autojanny: author_id = AUTOJANNY_ID
|
||||
else: author_id = NOTIFICATIONS_ID
|
||||
|
||||
text = text.replace('r/', 'r\/').replace('u/', 'u\/')
|
||||
text_html = sanitize(CustomRenderer().render(mistletoe.Document(text)))
|
||||
new_comment = Comment(author_id=author_id,
|
||||
parent_submission=None,
|
||||
distinguish_level=6,
|
||||
body=text,
|
||||
created_utc=0,
|
||||
body_html=text_html)
|
||||
g.db.add(new_comment)
|
||||
g.db.flush()
|
||||
return new_comment.id
|
||||
|
||||
def send_repeatable_notification(uid, text, autojanny=False):
|
||||
|
||||
if autojanny: author_id = AUTOJANNY_ID
|
||||
else: author_id = NOTIFICATIONS_ID
|
||||
|
||||
existing = g.db.query(Comment.id).filter_by(author_id=author_id, parent_submission=None, distinguish_level=6, body=text, created_utc=0).first()
|
||||
if existing:
|
||||
existing2 = g.db.query(Notification.id).filter_by(user_id=uid, comment_id=existing[0]).first()
|
||||
if existing2:
|
||||
text_html = sanitize(CustomRenderer().render(mistletoe.Document(text)))
|
||||
new_comment = Comment(author_id=author_id,
|
||||
parent_submission=None,
|
||||
distinguish_level=6,
|
||||
body=text,
|
||||
body_html=text_html,
|
||||
created_utc=0)
|
||||
g.db.add(new_comment)
|
||||
g.db.flush()
|
||||
notif = Notification(comment_id=new_comment.id, user_id=uid)
|
||||
g.db.add(notif)
|
||||
return
|
||||
existing_comment = g.db.query(Comment.id).filter_by(author_id=author_id, parent_submission=None, distinguish_level=6, body=text, created_utc=0).first()
|
||||
|
||||
send_notification(uid, text, autojanny)
|
||||
if existing_comment:
|
||||
cid = existing_comment[0]
|
||||
existing_notif = g.db.query(Notification.id).filter_by(user_id=uid, comment_id=cid).first()
|
||||
if existing_notif: cid = create_comment(text, autojanny)
|
||||
else: cid = create_comment(text, autojanny)
|
||||
|
||||
notif = Notification(comment_id=cid, user_id=uid)
|
||||
g.db.add(notif)
|
||||
|
||||
|
||||
def send_notification(uid, text, autojanny=False):
|
||||
|
@ -41,27 +47,14 @@ def send_notification(uid, text, autojanny=False):
|
|||
|
||||
def notif_comment(text, autojanny=False):
|
||||
|
||||
text = text.replace('r/', 'r\/').replace('u/', 'u\/')
|
||||
|
||||
if autojanny: author_id = AUTOJANNY_ID
|
||||
else: author_id = NOTIFICATIONS_ID
|
||||
|
||||
|
||||
existing = g.db.query(Comment.id).filter_by(author_id=author_id, parent_submission=None, distinguish_level=6, body=text, created_utc=0).first()
|
||||
|
||||
if existing: cid = existing[0]
|
||||
else:
|
||||
text_html = sanitize(CustomRenderer().render(mistletoe.Document(text)))
|
||||
new_comment = Comment(author_id=author_id,
|
||||
parent_submission=None,
|
||||
distinguish_level=6,
|
||||
body=text,
|
||||
body_html=text_html,
|
||||
created_utc=0)
|
||||
g.db.add(new_comment)
|
||||
g.db.flush()
|
||||
cid = new_comment.id
|
||||
if existing: return existing[0]
|
||||
else: return create_comment(text, autojanny)
|
||||
|
||||
return cid
|
||||
|
||||
def add_notif(cid, uid):
|
||||
existing = g.db.query(Notification.id).filter_by(comment_id=cid, user_id=uid).first()
|
||||
|
@ -69,6 +62,7 @@ def add_notif(cid, uid):
|
|||
notif = Notification(comment_id=cid, user_id=uid)
|
||||
g.db.add(notif)
|
||||
|
||||
|
||||
def send_admin(vid, text):
|
||||
|
||||
text_html = Renderer().render(mistletoe.Document(text))
|
||||
|
@ -89,6 +83,7 @@ def send_admin(vid, text):
|
|||
notif = Notification(comment_id=new_comment.id, user_id=admin.id)
|
||||
g.db.add(notif)
|
||||
|
||||
|
||||
def NOTIFY_USERS(text, vid):
|
||||
text = text.lower()
|
||||
notify_users = set()
|
||||
|
|
|
@ -23,6 +23,15 @@ if SITE_NAME == 'PCM': cc = "splash mountain"
|
|||
else: cc = "country club"
|
||||
month = datetime.now().strftime('%B')
|
||||
|
||||
@app.get("/admin/grassed")
|
||||
@admin_level_required(3)
|
||||
def grassed(v):
|
||||
users = g.db.query(User).filter(User.ban_reason.like('grass award used by @%')).all()
|
||||
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}grassed.html", v=v, users=users)
|
||||
|
||||
@app.get("/distribute/<cid>")
|
||||
@admin_level_required(3)
|
||||
def distribute(v, cid):
|
||||
|
@ -262,7 +271,6 @@ def shadowbanned(v):
|
|||
else: template = 'CHRISTMAS/'
|
||||
return render_template(f"{template}shadowbanned.html", v=v, users=users)
|
||||
|
||||
|
||||
@app.get("/admin/agendaposters")
|
||||
@auth_required
|
||||
def agendaposters(v):
|
||||
|
@ -887,6 +895,7 @@ def unban_user(user_id, v):
|
|||
user.is_banned = 0
|
||||
user.unban_utc = 0
|
||||
user.ban_evade = 0
|
||||
user.ban_reason = None
|
||||
g.db.add(user)
|
||||
|
||||
if request.values.get("alts", ""):
|
||||
|
|
|
@ -240,6 +240,7 @@ def award_post(pid, v):
|
|||
author.ban_reason = f"grass award used by @{v.username} on /post/{post.id}"
|
||||
link = f"[this post]({post.permalink})"
|
||||
send_repeatable_notification(author.id, f"Your account has been suspended permanently for {link}. You must [provide the admins](/contact) a timestamped picture of you touching grass to get unbanned!")
|
||||
send_repeatable_notification(CARP_ID, f"@{v.username} used {kind} award on [{post.shortlink}]({post.shortlink})")
|
||||
elif kind == "pin":
|
||||
if post.stickied and post.stickied.startswith("t:"): t = int(post.stickied[2:]) + 3600
|
||||
else: t = int(time.time()) + 3600
|
||||
|
@ -411,6 +412,7 @@ def award_comment(cid, v):
|
|||
author.ban_reason = f"grass award used by @{v.username} on /comment/{c.id}"
|
||||
link = f"[this comment]({c.permalink})"
|
||||
send_repeatable_notification(author.id, f"Your account has been suspended permanently for {link}. You must [provide the admins](/contact) a timestamped picture of you touching grass to get unbanned!")
|
||||
send_repeatable_notification(CARP_ID, f"@{v.username} used {kind} award on [{c.shortlink}]({c.shortlink})")
|
||||
elif kind == "pin":
|
||||
if c.is_pinned and c.is_pinned.startswith("t:"): t = int(c.is_pinned[2:]) + 3600
|
||||
else: t = int(time.time()) + 3600
|
||||
|
|
|
@ -104,10 +104,10 @@ def cached_chart(days):
|
|||
days = int((nowstamp - firstsignup) / 86400)
|
||||
|
||||
if days > 31:
|
||||
file = "/weekly_chart.png"
|
||||
file = "/weekly_chart.webp"
|
||||
day_cutoffs = [today_cutoff - 86400 * 7 * i for i in range(31)][1:]
|
||||
else:
|
||||
file = "/daily_chart.png"
|
||||
file = "/daily_chart.webp"
|
||||
day_cutoffs = [today_cutoff - 86400 * i for i in range(31)][1:]
|
||||
|
||||
day_cutoffs.insert(0, calendar.timegm(now))
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
{% extends "CHRISTMAS/settings2.html" %}
|
||||
|
||||
{% block content %}
|
||||
<table class="table table-striped mb-5">
|
||||
<thead class="bg-primary text-white">
|
||||
<tr>
|
||||
<th style="font-weight:bold;">#</th>
|
||||
<th style="font-weight:bold;">Name</th>
|
||||
<th style="font-weight:bold;">Grasser</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{% for user in users %}
|
||||
<tr>
|
||||
<td style="font-weight:bold;">{{loop.index}}</td>
|
||||
<td><a style="color:#{{user.namecolor}}; font-weight:bold;" href="/@{{user.username}}"><img loading="lazy" src="/uid/{{user.id}}/pic" class="pp20"><span {% if user.patron %}class="patron" style="background-color:#{{user.namecolor}};"{% endif %}>{{user.username}}</span></a></td>
|
||||
<td style="font-weight:bold;">{{user.ban_reason.split('by ')[1]}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
{% endblock %}
|
|
@ -807,7 +807,7 @@
|
|||
|
||||
{% if v %}
|
||||
<script src="/assets/js/marked.js?v=191"></script>
|
||||
<script src="/assets/js/comments_v.js?v=191"></script>
|
||||
<script src="/assets/js/comments_v.js?v=192"></script>
|
||||
{% endif %}
|
||||
|
||||
<script src="/assets/js/clipboard.js?v=190"></script>
|
||||
|
|
|
@ -81,7 +81,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/assets/js/emoji_modal.js?v=195"></script>
|
||||
<script src="/assets/js/emoji_modal.js?v=196"></script>
|
||||
|
||||
<style>
|
||||
a.emojitab {
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
{% extends "settings2.html" %}
|
||||
|
||||
{% block content %}
|
||||
<table class="table table-striped mb-5">
|
||||
<thead class="bg-primary text-white">
|
||||
<tr>
|
||||
<th style="font-weight:bold;">#</th>
|
||||
<th style="font-weight:bold;">Name</th>
|
||||
<th style="font-weight:bold;">Grasser</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{% for user in users %}
|
||||
<tr>
|
||||
<td style="font-weight:bold;">{{loop.index}}</td>
|
||||
<td><a style="color:#{{user.namecolor}}; font-weight:bold;" href="/@{{user.username}}"><img loading="lazy" src="/uid/{{user.id}}/pic" class="pp20"><span {% if user.patron %}class="patron" style="background-color:#{{user.namecolor}};"{% endif %}>{{user.username}}</span></a></td>
|
||||
<td style="font-weight:bold;">{{user.ban_reason.split('by ')[1]}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
{% endblock %}
|
Loading…
Reference in New Issue