diff --git a/chart.png b/chart.png deleted file mode 100644 index b341176aa..000000000 Binary files a/chart.png and /dev/null differ diff --git a/files/__main__.py b/files/__main__.py index 3cd73176f..f30308c00 100644 --- a/files/__main__.py +++ b/files/__main__.py @@ -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))) diff --git a/files/assets/js/comments_v.js b/files/assets/js/comments_v.js index 793d55570..8abdff9b4 100644 --- a/files/assets/js/comments_v.js +++ b/files/assets/js/comments_v.js @@ -215,12 +215,15 @@ document.onpaste = function(event) { var fullname = focused.dataset.fullname; f=document.getElementById('file-upload-reply-' + fullname); files = event.clipboardData.files - filename = files[0].name.toLowerCase() - if (filename.endsWith(".jpg") || filename.endsWith(".jpeg") || filename.endsWith(".png") || filename.endsWith(".webp") || filename.endsWith(".gif")) - { - f.files = files; - document.getElementById('filename-show-reply-' + fullname).textContent = filename; + try { + filename = files[0].name.toLowerCase() + if (filename.endsWith(".jpg") || filename.endsWith(".jpeg") || filename.endsWith(".png") || filename.endsWith(".webp") || filename.endsWith(".gif")) + { + f.files = files; + document.getElementById('filename-show-reply-' + fullname).textContent = filename; + } } + catch(e) {} } else if (focused.id.includes('comment-edit-body-')) { var id = focused.dataset.id; diff --git a/files/assets/js/emoji_modal.js b/files/assets/js/emoji_modal.js index 3aa2f5d23..87ad8f51d 100644 --- a/files/assets/js/emoji_modal.js +++ b/files/assets/js/emoji_modal.js @@ -860,8 +860,8 @@ function loadEmojis(form) { let search_bar = document.getElementById("emoji_search"); let search_container = document.getElementById('emoji-tab-search') - let container = document.getElementById(EMOJI_BOX_ID) - container.setAttribute(EMOJI_FORM_DESTINATION_ATTR, form) + let fav = document.getElementById(EMOJI_BOX_ID) + fav.setAttribute(EMOJI_FORM_DESTINATION_ATTR, form) const commentBox = document.getElementById(form); commentBox.setAttribute(TEXTAREA_POS_ATTR, commentBox.selectionStart); diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index d51d1d7b0..e14c4dcc3 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -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() diff --git a/files/routes/admin.py b/files/routes/admin.py index 810cc3256..8808bfdb2 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -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/") @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", ""): diff --git a/files/routes/awards.py b/files/routes/awards.py index bfd36e96c..11f5f91d0 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -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 diff --git a/files/routes/static.py b/files/routes/static.py index d8263f205..16f4602fc 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -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)) diff --git a/files/templates/CHRISTMAS/grassed.html b/files/templates/CHRISTMAS/grassed.html new file mode 100644 index 000000000..0c7ce6142 --- /dev/null +++ b/files/templates/CHRISTMAS/grassed.html @@ -0,0 +1,21 @@ +{% extends "CHRISTMAS/settings2.html" %} + +{% block content %} + + + + + + + + +{% for user in users %} + + + + + +{% endfor %} +
#NameGrasser
{{loop.index}}{{user.username}}{{user.ban_reason.split('by ')[1]}}
+ +{% endblock %} diff --git a/files/templates/comments.html b/files/templates/comments.html index 56316c1dd..22fe594dd 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -807,7 +807,7 @@ {% if v %} - + {% endif %} diff --git a/files/templates/emoji_modal.html b/files/templates/emoji_modal.html index f3a4a4d8e..8a0f62ce9 100644 --- a/files/templates/emoji_modal.html +++ b/files/templates/emoji_modal.html @@ -81,7 +81,7 @@ - +