diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 5c3474e9c..ef88ac6e9 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -227,7 +227,7 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False): if remoji == 'marseyrandom': remoji = choice(marseys) if path.isfile(f'files/assets/images/emojis/{remoji}.webp'): - new = re.sub(f'(?', new, flags=re.I) + new = re.sub(f'(?', new, flags=re.I) if comment: marseys_used.add(emoji) sanitized = sanitized.replace(old, new) @@ -251,7 +251,7 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False): else: emoji = old if path.isfile(f'files/assets/images/emojis/{emoji}.webp'): - sanitized = re.sub(f'(?', sanitized, flags=re.I) + sanitized = re.sub(f'(?', sanitized, flags=re.I) if comment: marseys_used.add(emoji) else: classes = 'emoji' @@ -262,7 +262,7 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False): else: emoji = old if path.isfile(f'files/assets/images/emojis/{emoji}.webp'): - sanitized = re.sub(f'(?', sanitized, flags=re.I) + sanitized = re.sub(f'(?', sanitized, flags=re.I) if comment: marseys_used.add(emoji) sanitized = sanitized.replace("https://youtu.be/", "https://youtube.com/watch?v=").replace("https://music.youtube.com/watch?v=", "https://youtube.com/watch?v=").replace("https://streamable.com/", "https://streamable.com/e/").replace("https://youtube.com/shorts/", "https://youtube.com/watch?v=").replace("https://mobile.twitter", "https://twitter").replace("https://m.facebook", "https://facebook").replace("m.wikipedia.org", "wikipedia.org").replace("https://m.youtube", "https://youtube").replace("https://www.youtube", "https://youtube") @@ -339,7 +339,7 @@ def filter_emojis_only(title, edit=False, graceful=False): else: emoji = old if path.isfile(f'files/assets/images/emojis/{emoji}.webp'): - title = re.sub(f'(?', title, flags=re.I) + title = re.sub(f'(?', title, flags=re.I) else: classes = 'emoji' @@ -350,7 +350,7 @@ def filter_emojis_only(title, edit=False, graceful=False): else: emoji = old if path.isfile(f'files/assets/images/emojis/{emoji}.webp'): - title = re.sub(f'(?', title, flags=re.I) + title = re.sub(f'(?', title, flags=re.I) title = re.sub('~~(.*?)~~', r'\1', title) diff --git a/files/routes/comments.py b/files/routes/comments.py index ada4a3ab7..4b1d20fa2 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -280,7 +280,7 @@ def api_comment(v): filename = f'files/assets/images/emojis/{name}.webp' copyfile(oldname, filename) process_image(filename, 200) - requests.post(f'https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/purge_cache', headers=CF_HEADERS, data={'files': [f"https://{request.host}/static/assets/images/emojis/{name}.webp"]}, timeout=5) + requests.post(f'https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/purge_cache', headers=CF_HEADERS, data={'files': [f"https://{request.host}/e/{name}"]}, timeout=5) cache.delete_memoized(marsey_list) except Exception as e: return {"error": str(e)}, 400 diff --git a/files/routes/front.py b/files/routes/front.py index e424945ad..cf2960a72 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -41,7 +41,7 @@ def notifications(v): messages = request.values.get('messages') modmail = request.values.get('modmail') posts = request.values.get('posts') - if modmail and v.admin_level > 1: + if modmail and v.admin_level > 2: comments = g.db.query(Comment).filter(Comment.sentto==2).order_by(Comment.id.desc()).offset(25*(page-1)).limit(26).all() next_exists = (len(comments) > 25) comments = comments[:25] diff --git a/files/routes/posts.py b/files/routes/posts.py index 9b754de26..8bf380d06 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -761,9 +761,7 @@ def thumbnail_thread(pid): word = random.choice(('rdrama','marsey')) try: - data = requests.get(f'https://api.pushshift.io/reddit/{t}/search?html_decode=true&q={word}&size=1', timeout=5) - if str(data) == "": data = data.json()["data"] - else: break + data = requests.get(f'https://api.pushshift.io/reddit/{t}/search?html_decode=true&q={word}&size=1', timeout=5).json()["data"] except: break for i in data: @@ -789,7 +787,11 @@ def thumbnail_thread(pid): k,val = random.choice(tuple(REDDIT_NOTIFS.items())) - for i in requests.get(f'https://api.pushshift.io/reddit/{t}/search?html_decode=true&q={k}&size=1', timeout=5).json()["data"]: + try: + data = requests.get(f'https://api.pushshift.io/reddit/{t}/search?html_decode=true&q={k}&size=1', timeout=5).json()["data"] + except: break + + for i in data: body_html = sanitize(f'New mention of you: https://old.reddit.com{i["permalink"]}?context=89', noimages=True) existing_comment = db.query(Comment.id).filter_by(author_id=NOTIFICATIONS_ID, parent_submission=None, distinguish_level=6, body_html=body_html).one_or_none() @@ -813,8 +815,6 @@ def thumbnail_thread(pid): try: data = requests.get(f'https://api.pushshift.io/reddit/{t}/search?html_decode=true&q=pcmemes.net&size=1', timeout=5).json()["data"] - if str(data) == "": data = data.json()["data"] - else: break except: break for i in data: diff --git a/files/routes/static.py b/files/routes/static.py index 1a7591376..8b1da44b1 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -314,7 +314,7 @@ def submit_contact(v): ) g.db.add(new_comment) g.db.flush() - for admin in g.db.query(User).filter(User.admin_level > 1).all(): + for admin in g.db.query(User).filter(User.admin_level > 2).all(): notif = Notification(comment_id=new_comment.id, user_id=admin.id) g.db.add(notif) @@ -333,6 +333,16 @@ def archives(path): if request.path.endswith('.css'): resp.headers.add("Content-Type", "text/css") return resp +@app.get('/e/') +@limiter.exempt +def emoji(emoji): + resp = make_response(send_from_directory('assets/images/emojis', f'{emoji}.webp')) + resp.headers.remove("Cache-Control") + resp.headers.add("Cache-Control", "public, max-age=3153600") + resp.headers.remove("Content-Type") + resp.headers.add("Content-Type", "image/webp") + return resp + @app.get('/assets/') @app.get('/static/assets/') @limiter.exempt diff --git a/files/templates/comments.html b/files/templates/comments.html index 59e69c054..c6c06619d 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -873,7 +873,7 @@ {% endif %} {% if v %} - + {% endif %} diff --git a/files/templates/emoji_modal.html b/files/templates/emoji_modal.html index 3d54135b6..a3249055a 100644 --- a/files/templates/emoji_modal.html +++ b/files/templates/emoji_modal.html @@ -106,4 +106,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/files/templates/errors/400.html b/files/templates/errors/400.html index f40e619c9..19252653b 100644 --- a/files/templates/errors/400.html +++ b/files/templates/errors/400.html @@ -10,7 +10,7 @@
- :#marseybrainlet: + :#marseybrainlet:

 			

400 Bad Request

That request was bad and you should feel bad.

diff --git a/files/templates/errors/401.html b/files/templates/errors/401.html index b3f675fae..f0103a28e 100644 --- a/files/templates/errors/401.html +++ b/files/templates/errors/401.html @@ -11,7 +11,7 @@
- :#marseydead: + :#marseydead:

 
 			

401 Not Authorized

diff --git a/files/templates/errors/403.html b/files/templates/errors/403.html index 0977c0d9d..480a39b8c 100644 --- a/files/templates/errors/403.html +++ b/files/templates/errors/403.html @@ -10,7 +10,7 @@
- :#marseytroll: + :#marseytroll:

 		

403 Forbidden

YOU AREN'T WELCOME HERE GO AWAY

diff --git a/files/templates/errors/404.html b/files/templates/errors/404.html index 58b43e882..e6485a705 100644 --- a/files/templates/errors/404.html +++ b/files/templates/errors/404.html @@ -10,7 +10,7 @@
- :#marseyconfused + :#marseyconfused

 		

404 Page Not Found

Someone typed something wrong and it was probably you, please do better.

diff --git a/files/templates/errors/405.html b/files/templates/errors/405.html index fc10cd830..d049497cb 100644 --- a/files/templates/errors/405.html +++ b/files/templates/errors/405.html @@ -10,7 +10,7 @@
- :#marseyretard: + :#marseyretard:

 		

405 Method Not Allowed

idk how anyone gets this error but if you see this, remember to follow @carpathianflorist
the original error text here talked about internet gremlins and wtf

diff --git a/files/templates/errors/429.html b/files/templates/errors/429.html index c11373adb..8533b7873 100644 --- a/files/templates/errors/429.html +++ b/files/templates/errors/429.html @@ -10,7 +10,7 @@
- :#marseyrentfree: + :#marseyrentfree:

 		

429 Too Many Requests

go spam somewhere else nerd

diff --git a/files/templates/errors/500.html b/files/templates/errors/500.html index 6ec3ce96e..c85f081a8 100644 --- a/files/templates/errors/500.html +++ b/files/templates/errors/500.html @@ -10,7 +10,7 @@
- :#marseydead: + :#marseydead:

 			

500 Internal Server Error

Hiiiii it's carp! I think this error means that there's a timeout error. And I think that means something took too long to load so it decided not to work at all. If you keep seeing this on the same page but not other pages, then something is probably wrong with that specific function. It may not be called a function, but that sounds right to me. Anyway, ping me and I'll whine to someone smarter to fix it. Don't bother them. Thanks ily <3

diff --git a/files/templates/errors/nsfw.html b/files/templates/errors/nsfw.html index c34ca546c..e3579fb00 100644 --- a/files/templates/errors/nsfw.html +++ b/files/templates/errors/nsfw.html @@ -10,7 +10,7 @@
- :#marseytwerking: + :#marseytwerking:

Are you over 18?

This post is rated +18 (Adult-Only). You must be 18 or older to continue. Are you sure you want to proceed?

diff --git a/files/templates/errors/patron.html b/files/templates/errors/patron.html index 97bfd61c5..3b49c7ca5 100644 --- a/files/templates/errors/patron.html +++ b/files/templates/errors/patron.html @@ -11,7 +11,7 @@
- :#marseymerchant: + :#marseymerchant:

401 Not Authorized

This page is only available to {% if SITE_NAME == 'Drama' %}paypigs{% else %}patrons{% endif %}:

{{config('GUMROAD_LINK')}} diff --git a/files/templates/formatting.html b/files/templates/formatting.html index bdb08a52e..220a3faff 100644 --- a/files/templates/formatting.html +++ b/files/templates/formatting.html @@ -69,22 +69,22 @@ You can use Markdown formatting: Emojis :marseylove: - :marseylove: + :marseylove: Mirrored Emojis :!marseylove: - :!marseylove: + :!marseylove: Large Emojis :#marseylove: - :!marseylove: + :!marseylove: Large Mirrored Emojis :#!marseylove: - :!marseylove: + :!marseylove: Random Marsey diff --git a/files/templates/header.html b/files/templates/header.html index 31b006ea4..e2c04d7ec 100644 --- a/files/templates/header.html +++ b/files/templates/header.html @@ -33,7 +33,7 @@ {% if SITE_NAME == 'Drama' %} {% set icon = ('marseyblm','marseykween','marseydynamite','marseyblack','marseymyeisha','marseyetika','marseyobama','marseyblackcop','marseysosa','marseyblackface')|random() %} - header icon + header icon {% else %} header icon {% endif %} diff --git a/files/templates/log.html b/files/templates/log.html index a81236637..21479f251 100644 --- a/files/templates/log.html +++ b/files/templates/log.html @@ -56,10 +56,10 @@