From 000b4f4c37a2ceff938394e84d89c6bf55e69ce0 Mon Sep 17 00:00:00 2001 From: justcool393 Date: Mon, 14 Nov 2022 11:17:29 -0600 Subject: [PATCH] can post in ghost threads --- files/classes/user.py | 10 ++++++++++ files/helpers/const.py | 4 ++++ files/routes/comments.py | 1 + files/routes/posts.py | 2 +- 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/files/classes/user.py b/files/classes/user.py index e2972241a..370442fa9 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -975,6 +975,16 @@ class User(Base): if self.agendaposter: return True if self.patron: return True return False + + @property + @lazy + def can_post_in_ghost_threads(self): + if not TRUESCORE_GHOST_LIMIT: return True + if self.admin_level >= PERMS['POST_IN_GHOST_THREADS']: return True + if self.club_allowed: return True + if self.truescore >= TRUESCORE_GHOST_LIMIT: return True + if self.patron: return True + return False @property @lazy diff --git a/files/helpers/const.py b/files/helpers/const.py index 0c2f44791..1b26641b6 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -229,6 +229,7 @@ PERMS = { # Minimum admin_level to perform action. 'USER_MERGE': 3, # note: extra check for Aevann 'USER_TITLE_CHANGE': 2, 'USER_MODERATION_TOOLS_VISIBLE': 2, # note: does not affect API at all + 'POST_IN_GHOST_THREADS': 1, 'POST_TO_CHANGELOG': 1, # note: code contributors can also post to changelog 'POST_TO_POLL_THREAD': 2, 'POST_BETS': 3, @@ -378,6 +379,7 @@ MIN_REPOST_CHECK_URL_LENGTH = 9 # also change the constant in checkRepost() of s TRUESCORE_DONATE_LIMIT = 100 COSMETIC_AWARD_COIN_AWARD_PCT = 0.10 TRUESCORE_CHAT_LIMIT = 0 +TRUESCORE_GHOST_LIMIT = 0 POST_GHOST_COST = 100 LOGGEDIN_ACTIVE_TIME = 15 * 60 @@ -476,6 +478,7 @@ if SITE == 'rdrama.net': NOTIFICATION_THREAD = 6489 TRUESCORE_CHAT_LIMIT = 10 + TRUESCORE_GHOST_LIMIT = 10 HOLE_COST = 50000 HOLE_INACTIVITY_DELETION = True @@ -570,6 +573,7 @@ elif SITE == 'watchpeopledie.tv': BANNER_THREAD = 9869 TRUESCORE_CHAT_LIMIT = 10 + TRUESCORE_GHOST_LIMIT = 10 HOLE_NAME = 'flair' HOLE_STYLE_FLAIR = True diff --git a/files/routes/comments.py b/files/routes/comments.py index 2e1109550..f40b503b9 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -102,6 +102,7 @@ def comment(v): parent_post = get_post(parent.parent_submission, v=v) parent_comment_id = parent.id if parent.author_id == v.id: rts = True + if not v.can_post_in_ghost_threads: abort(403, f"You need {TRUESCORE_GHOST_LIMIT} truescore to post in ghost threads") else: abort(400) level = 1 if isinstance(parent, Submission) else parent.level + 1 diff --git a/files/routes/posts.py b/files/routes/posts.py index 571aa4c72..787475f63 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -785,7 +785,7 @@ def submit_post(v, sub=None): flag_over_18 = request.values.get("over_18", False, bool) flag_private = request.values.get("private", False, bool) flag_club = (request.values.get("club", False, bool) and FEATURES['COUNTRY_CLUB']) - flag_ghost = request.values.get("ghost", False, bool) and v.charge_account('coins', POST_GHOST_COST) + flag_ghost = request.values.get("ghost", False, bool) and v.can_post_in_ghost_threads if embed and len(embed) > 1500: embed = None if embed: embed = embed.strip()