From 333d1bd6da56dcc55acb60334fe5a44e06c438a6 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sun, 5 Sep 2021 19:55:36 +0200 Subject: [PATCH] gf --- files/helpers/sanitize.py | 7 +++++++ files/routes/admin.py | 13 ------------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index f97463828..183d1090a 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -215,9 +215,16 @@ def sanitize(sanitized, noimages=False): if path.isfile(f'./files/assets/images/emojis/{i.group(1)}.gif'): sanitized = sanitized.replace(f'

:{i.group(1)}:

', f'

') + if session.get(i.group(1)): session[i.group(1)] += 1 + else: session[i.group(1)] = 1 + for i in re.finditer(':([^ ]{1,30}?):', sanitized): if path.isfile(f'./files/assets/images/emojis/{i.group(1)}.gif'): sanitized = sanitized.replace(f':{i.group(1)}:', f'') + + if session.get(i.group(1)): session[i.group(1)] += 1 + else: session[i.group(1)] = 1 + sanitized = sanitized.replace("https://www.", "https://").replace("https://youtu.be/", "https://youtube.com/watch?v=").replace("https://music.youtube.com/watch?v=", "https://youtube.com/watch?v=").replace("https://open.spotify.com/", "https://open.spotify.com/embed/").replace("https://streamable.com/", "https://streamable.com/e/").replace("https://youtube.com/shorts/", "https://youtube.com/watch?v=").replace("https://mobile.", "https://").replace("https://m.", "https://") diff --git a/files/routes/admin.py b/files/routes/admin.py index 93fbace37..30ac2dfbc 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -22,19 +22,6 @@ from files.helpers.discord import add_role IMGUR_KEY = environ.get("IMGUR_KEY", "").strip() -@app.get("/admin/received_awards") -@admin_level_required(6) -def received_awards(v): - for u in g.db.query(User).options(lazyload('*')).all(): - posts_idlist = g.db.query(Submission.id).filter_by(author_id=u.id).subquery() - comments_idlist = g.db.query(Comment.id).filter_by(author_id=u.id).subquery() - - post_awards = g.db.query(AwardRelationship).filter(AwardRelationship.submission_id.in_(posts_idlist)).count() - comment_awards = g.db.query(AwardRelationship).filter(AwardRelationship.comment_id.in_(comments_idlist)).count() - u.received_award_count = post_awards + comment_awards - g.db.add(u) - return "sex" - @app.get("/imgurcredits") @admin_level_required(6) def imgurcredits(v):