From 81a6bcfdc0311f0020f60ccad8de12bbce790ede Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 4 Dec 2021 22:48:10 +0200 Subject: [PATCH] fsdfsd --- files/classes/comment.py | 5 ++++- files/classes/submission.py | 5 ++++- files/helpers/const.py | 3 +++ files/routes/awards.py | 4 ++++ files/routes/discord.py | 2 +- files/routes/settings.py | 11 +++++++++++ 6 files changed, 27 insertions(+), 3 deletions(-) diff --git a/files/classes/comment.py b/files/classes/comment.py index d299cc3bb..dd6edb792 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -335,8 +335,11 @@ class Comment(Base): maxupvotes = min(ti, 31) rand = randint(0, maxupvotes) if self.upvotes < rand: - self.upvotes += randint(0, 3) + amount = randint(0, 3) + self.upvotes += amount g.db.add(self) + self.author.coins += amount + g.db.add(self.author) g.db.commit() return body diff --git a/files/classes/submission.py b/files/classes/submission.py index 3a306d5a3..668b9cd7a 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -335,8 +335,11 @@ class Submission(Base): maxupvotes = min(ti, 27) rand = random.randint(0, maxupvotes) if self.upvotes < rand: - self.upvotes += random.randint(0, 3) + amount = random.randint(0, 3) + self.upvotes += amount g.db.add(self) + self.author.coins += amount + g.db.add(self.author) g.db.commit() return body diff --git a/files/helpers/const.py b/files/helpers/const.py index 2dc60d358..a5b7d62bb 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -143,6 +143,7 @@ if SITE == 'rdrama.net': CARP_ID = 995 JOAN_ID = 28 AEVANN_ID = 1 + KLEN_ID = 2050 LAWLZ_ID = 3833 LLM_ID = 253 DAD_ID = 2513 @@ -164,6 +165,7 @@ elif SITE == "pcmemes.net": CARP_ID = 0 JOAN_ID = 0 AEVANN_ID = 1 + KLEN_ID = 0 LAWLZ_ID = 0 LLM_ID = 0 DAD_ID = 0 @@ -185,6 +187,7 @@ else: CARP_ID = 0 JOAN_ID = 0 AEVANN_ID = 0 + KLEN_ID = 0 LAWLZ_ID = 0 LLM_ID = 0 DAD_ID = 0 diff --git a/files/routes/awards.py b/files/routes/awards.py index 2013cf00a..716cb4bad 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -447,6 +447,8 @@ def buy(v, award): @auth_required def award_post(pid, v): + if v.shadowbanned: return render_template('errors/500.html', v=v), 500 + if v.is_banned and not v.unban_utc: return {"error": "forbidden."}, 403 kind = request.values.get("kind", "").strip() @@ -602,6 +604,8 @@ def award_post(pid, v): @auth_required def award_comment(cid, v): + if v.shadowbanned: return render_template('errors/500.html', v=v), 500 + if v.is_suspended and v.unban_utc == 0: return {"error": "forbidden"}, 403 kind = request.values.get("kind", "").strip() diff --git a/files/routes/discord.py b/files/routes/discord.py index 4ffc60f3d..11d0cee76 100644 --- a/files/routes/discord.py +++ b/files/routes/discord.py @@ -19,7 +19,7 @@ def join_discord(v): if v.is_suspended != 0 and v.admin_level == 0: return "Banned users cannot join the discord server!" - if SITE_NAME == 'Drama' and v.admin_level == 0 and v.patron == 0 and v.truecoins < 150: return f"You must earn 150 {COINS_NAME} before entering the Discord server. You earn {COINS_NAME} by making posts/comments and getting upvoted." + if SITE_NAME == 'Drama' and v.admin_level == 0 and v.patron == 0 and v.truecoins < 150: return f"You must receive 150 upvotes/downvotes from other users before being able to join the Discord server." if v.shadowbanned or v.agendaposter: return "" diff --git a/files/routes/settings.py b/files/routes/settings.py index c36112e70..5dab1f9d6 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -338,6 +338,17 @@ def settings_profile_post(v): if len(bio_html) > 10000: abort(400) + if v.id == KLEN_ID: + notify_users = NOTIFY_USERS(friends_html, v.id) + soup = BeautifulSoup(friends_html, features="html.parser") + for mention in soup.find_all("a", href=re.compile("^/@(\w+)")): + username = mention["href"].split("@")[1] + user = g.db.query(User).filter_by(username=username).first() + if user and not v.any_block_exists(user) and user.id != v.id: notify_users.add(user.id) + for x in notify_users: + message = f"@{v.username} has added you to their friends list!" + send_notification(x, message) + v.bio = bio[:1500] v.bio_html=bio_html g.db.add(v)