diff --git a/Dockerfile b/Dockerfile index 20c190ea0..494da0606 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,16 @@ FROM ubuntu:20.04 -RUN apt update && apt -y upgrade && apt install -y python3.8 python3-pip supervisor libenchant1c2a +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/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/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) diff --git a/files/routes/comments.py b/files/routes/comments.py index 2896cdf2e..e22afab97 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -17,9 +17,14 @@ import requests from shutil import copyfile from json import loads from collections import Counter -from enchant import Dict -d = Dict("en_US") +import nltk +nltk.download('words') + +from nltk.corpus import words + +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 +1106,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..d48e24e1c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,6 +11,7 @@ gunicorn lxml mistletoe matplotlib +nltk Pillow psutil pyotp @@ -20,7 +21,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