From 42c9bb87fd19f49e902b44bd00fdc8b4d33f51e2 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 22 Feb 2022 14:39:02 +0200 Subject: [PATCH 1/3] df --- Dockerfile | 2 +- files/classes/exiles.py | 1 + files/routes/comments.py | 7 ++++--- files/routes/subs.py | 4 ++-- requirements.txt | 1 - ubuntu_setup | 2 +- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 20c190ea0..3f846d3de 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM ubuntu:20.04 -RUN apt update && apt -y upgrade && apt install -y python3.8 python3-pip supervisor libenchant1c2a +RUN apt update && apt -y upgrade && apt install -y supervisor python3-pip ffmpeg COPY supervisord.conf /etc/supervisord.conf diff --git a/files/classes/exiles.py b/files/classes/exiles.py index b2469e55a..d34b45999 100644 --- a/files/classes/exiles.py +++ b/files/classes/exiles.py @@ -7,6 +7,7 @@ class Exile(Base): __tablename__ = "exiles" user_id = Column(Integer, ForeignKey("users.id"), primary_key=True) sub = Column(String, ForeignKey("subs.name"), primary_key=True) + exiler_id = Column(Integer, ForeignKey("users.id")) def __repr__(self): return f"" \ No newline at end of file diff --git a/files/routes/comments.py b/files/routes/comments.py index 2896cdf2e..016c03ba6 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -17,9 +17,10 @@ import requests from shutil import copyfile from json import loads from collections import Counter -from enchant import Dict +from nltk.corpus import words -d = Dict("en_US") +words = set(WORDLE_LIST) | set(words.words()) +words = set([x for x in words if len(x) == 5]) IMGUR_KEY = environ.get("IMGUR_KEY").strip() @@ -1101,7 +1102,7 @@ def handle_wordle_action(cid, v): try: guess = request.values.get("guess").strip().lower() except: abort(400) - if len(guess) != 5 or not d.check(guess) and guess not in WORDLE_LIST: + if len(guess) != 5 or guess not in words: return {"error": "Not a valid guess!"}, 400 if status == "active": diff --git a/files/routes/subs.py b/files/routes/subs.py index 4bd3d9ad6..b69fcd8ab 100644 --- a/files/routes/subs.py +++ b/files/routes/subs.py @@ -26,7 +26,7 @@ def exile_post(v, pid): u = p.author if u.admin_level < 2 and not u.exiled_from(sub): - exile = Exile(user_id=u.id, sub=sub) + exile = Exile(user_id=u.id, sub=sub, exiler_id=v.id) g.db.add(exile) send_notification(u.id, f"@{v.username} has exiled you from /s/{sub} for [{p.title}]({p.sl})") @@ -79,7 +79,7 @@ def exile_comment(v, cid): u = c.author if u.admin_level < 2 and not u.exiled_from(sub): - exile = Exile(user_id=u.id, sub=sub) + exile = Exile(user_id=u.id, sub=sub, exiler_id=v.id) g.db.add(exile) send_notification(u.id, f"@{v.username} has exiled you from /s/{sub} for [{c.permalink}]({c.sl})") diff --git a/requirements.txt b/requirements.txt index 17a01ccb4..c757811c9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -20,7 +20,6 @@ requests SQLAlchemy psycopg2-binary pusher_push_notifications -pyenchant youtube-dl yattag webptools \ No newline at end of file diff --git a/ubuntu_setup b/ubuntu_setup index 31d8e61a9..521673c50 100644 --- a/ubuntu_setup +++ b/ubuntu_setup @@ -1,7 +1,7 @@ cd /Drama sudo apt update sudo apt -y upgrade -sudo apt -y install postgresql postgresql-contrib redis-server python3-pip gunicorn ffmpeg libenchant1c2a +sudo apt -y install postgresql postgresql-contrib redis-server python3-pip ffmpeg cp pg_hba.conf /etc/postgresql/12/main/pg_hba.conf sudo service postgresql restart sudo psql -U postgres -f schema.sql postgres From 9bfcbce7f746d2d04523e8225cd6c08e7ee454db Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 22 Feb 2022 14:40:43 +0200 Subject: [PATCH 2/3] xcv --- files/routes/comments.py | 4 ++++ requirements.txt | 1 + 2 files changed, 5 insertions(+) diff --git a/files/routes/comments.py b/files/routes/comments.py index 016c03ba6..e22afab97 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -17,6 +17,10 @@ import requests from shutil import copyfile from json import loads from collections import Counter + +import nltk +nltk.download('words') + from nltk.corpus import words words = set(WORDLE_LIST) | set(words.words()) diff --git a/requirements.txt b/requirements.txt index c757811c9..d48e24e1c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,6 +11,7 @@ gunicorn lxml mistletoe matplotlib +nltk Pillow psutil pyotp From 513d10e25a71e6711921a2151b152e194a49121a Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 22 Feb 2022 15:00:41 +0200 Subject: [PATCH 3/3] fdg --- Dockerfile | 12 +++++++++++- files/helpers/sanitize.py | 6 ++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3f846d3de..494da0606 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,16 @@ FROM ubuntu:20.04 -RUN apt update && apt -y upgrade && apt install -y supervisor python3-pip ffmpeg +RUN apt update + +RUN apt -y upgrade + +RUN apt install -y supervisor + +RUN apt install -y python3-pip + +RUN apt install -y python3-enchant + +RUN apt install -y libenchant1c2a COPY supervisord.conf /etc/supervisord.conf diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 9009eb09e..60f9adc13 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -113,7 +113,7 @@ def handler(signum, frame): def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False): signal.signal(signal.SIGALRM, handler) - signal.alarm(1) + signal.alarm(2) if sanitized.count(':') > 100: abort(418) if sanitized.count('@') > 50: abort(418) @@ -305,7 +305,7 @@ def handler2(signum, frame): def filter_emojis_only(title, edit=False, graceful=False): signal.signal(signal.SIGALRM, handler2) - signal.alarm(1) + signal.alarm(2) if title.count(':') > 100: abort(418) if title.count('@') > 50: abort(418) @@ -342,6 +342,8 @@ def filter_emojis_only(title, edit=False, graceful=False): if path.isfile(f'files/assets/images/emojis/{emoji}.webp'): title = re.sub(f'(?', title, re.I) + title = re.sub('~~(.*?)~~', r'\1', title) + signal.alarm(0) if len(title) > 1500 and not graceful: abort(400)