diff --git a/files/helpers/awards.py b/files/helpers/awards.py index e310ec7946..6986e59b67 100644 --- a/files/helpers/awards.py +++ b/files/helpers/awards.py @@ -76,6 +76,7 @@ def award_timers(v, bot=False): v.earlylife = None notify_if_not_bot("Your earlylife status has expired!") badge = v.has_badge(169) + if badge: g.db.delete(badge) if v.marsify and v.marsify < now and v.marsify != 1: v.marsify = 0 if SITE_NAME != 'rDrama': notify_if_not_bot("Your marsify status has expired!") diff --git a/files/helpers/jinja2.py b/files/helpers/jinja2.py index b4fcc7ed85..92251befec 100644 --- a/files/helpers/jinja2.py +++ b/files/helpers/jinja2.py @@ -8,10 +8,6 @@ from files.helpers.assetcache import assetcache_path @app.template_filter("post_embed") def post_embed(id, v): - - try: id = int(id) - except: return None - p = get_post(id, v, graceful=True) if p: return render_template("submission_listing.html", listing=[p], v=v) diff --git a/files/routes/admin.py b/files/routes/admin.py index c15df9715d..722a0fe797 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -300,11 +300,8 @@ def revert_actions(v, username): @limiter.limit("1/second;30/minute;200/hour;1000/day") @admin_level_required(2) def club_allow(v, username): - u = get_user(username, v=v) - if not u: abort(404) - if u.admin_level >= v.admin_level: return {"error": "noob"}, 400 u.club_allowed = True @@ -327,11 +324,8 @@ def club_allow(v, username): @limiter.limit("1/second;30/minute;200/hour;1000/day") @admin_level_required(2) def club_ban(v, username): - u = get_user(username, v=v) - if not u: abort(404) - if u.admin_level >= v.admin_level: return {"error": "noob"}, 400 u.club_allowed = False @@ -1121,12 +1115,7 @@ def mute_user(v, user_id, mute_status): @limiter.limit("1/second;30/minute;200/hour;1000/day") @admin_level_required(2) def remove_post(post_id, v): - post = get_post(post_id) - - if not post: - abort(400) - post.is_banned = True post.is_approved = None post.stickied = None @@ -1164,9 +1153,6 @@ def approve_post(post_id, v): if post.author.id == v.id and post.author.agendaposter and AGENDAPOSTER_PHRASE not in post.body.lower() and post.sub != 'chudrama': return {"error": "You can't bypass the chud award!"}, 400 - if not post: - abort(400) - if post.is_banned: ma=ModAction( kind="unban_post", @@ -1192,11 +1178,8 @@ def approve_post(post_id, v): @app.post("/distinguish/") @admin_level_required(1) def distinguish_post(post_id, v): - post = get_post(post_id) - if not post: abort(404) - if post.author_id != v.id and v.admin_level < 2 : abort(403) if post.distinguish_level: @@ -1227,7 +1210,7 @@ def sticky_post(post_id, v): abort(403) post = get_post(post_id) - if post and not post.stickied: + if not post.stickied: pins = g.db.query(Submission).filter(Submission.stickied != None, Submission.is_banned == False).count() if pins >= PIN_LIMIT: if v.admin_level > 2: @@ -1255,7 +1238,7 @@ def sticky_post(post_id, v): def unsticky_post(post_id, v): post = get_post(post_id) - if post and post.stickied: + if post.stickied: if post.stickied.endswith('(pin award)'): return {"error": "Can't unpin award pins!"}, 403 post.stickied = None @@ -1329,10 +1312,7 @@ def unsticky_comment(cid, v): @limiter.limit("1/second;30/minute;200/hour;1000/day") @admin_level_required(2) def remove_comment(c_id, v): - comment = get_comment(c_id) - if not comment: - abort(404) comment.is_banned = True comment.is_approved = None diff --git a/files/routes/awards.py b/files/routes/awards.py index 1d51b0ee9e..ff6486982b 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -133,8 +133,6 @@ def award_thing(v, thing_type, id): if thing_type == 'post': thing = get_post(id) else: thing = get_comment(id) - if not thing: return {"error": f"This {thing_type} doesn't exist."}, 404 - if v.shadowbanned: return render_template('errors/500.html', err=True, v=v), 500 kind = request.values.get("kind", "").strip() @@ -165,7 +163,7 @@ def award_thing(v, thing_type, id): note = request.values.get("note", "").strip() author = thing.author - if author.shadowbanned: return {"error": f"This {thing_type} doesn't exist."}, 404 + if author.shadowbanned: abort(404) if SITE == 'rdrama.net' and author.id in (PIZZASHILL_ID, CARP_ID): return {"error": "This user is immune to awards."}, 403 @@ -469,7 +467,7 @@ def admin_userawards_post(v): whitelist = ("shit", "fireflies", "train", "scooter", "wholesome", "tilt", "glowie") - u = get_user(u, graceful=False, v=v) + u = get_user(u, v=v) notify_awards = {} diff --git a/files/routes/posts.py b/files/routes/posts.py index 29dee0f558..062b1dd14e 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -234,8 +234,6 @@ def post_id(pid, anything=None, v=None, sub=None): @limiter.limit("1/second;30/minute;200/hour;1000/day") @auth_desired_with_logingate def viewmore(v, pid, sort, offset): - try: pid = int(pid) - except: abort(400) post = get_post(pid, v=v) if post.club and not (v and (v.paid_dues or v.id == post.author_id)): abort(403) diff --git a/files/routes/search.py b/files/routes/search.py index ae9ac3494a..92d4af1daa 100644 --- a/files/routes/search.py +++ b/files/routes/search.py @@ -72,7 +72,6 @@ def searchposts(v): if 'author' in criteria: posts = posts.filter(Submission.ghost == False) author = get_user(criteria['author'], v=v, include_shadowbanned=False) - if not author: return {"error": "User not found"}, 400 if author.is_private and author.id != v.id and v.admin_level < 2 and not v.eye: if request.headers.get("Authorization"): return {"error": f"@{author.username}'s profile is private; You can't use the 'author' syntax on them"}, 400 @@ -209,7 +208,6 @@ def searchcomments(v): if 'author' in criteria: comments = comments.filter(Comment.ghost == False) author = get_user(criteria['author'], v=v, include_shadowbanned=False) - if not author: return {"error": "User not found"}, 400 if author.is_private and author.id != v.id and v.admin_level < 2 and not v.eye: if request.headers.get("Authorization"): return {"error": f"@{author.username}'s profile is private; You can't use the 'author' syntax on them"}, 400 diff --git a/files/routes/subs.py b/files/routes/subs.py index 56fd7f7b29..516ee789f3 100644 --- a/files/routes/subs.py +++ b/files/routes/subs.py @@ -48,9 +48,6 @@ def exile_post(v, pid): @is_not_permabanned def exile_comment(v, cid): if v.shadowbanned: return {"error": "Internal Server Error"}, 500 - try: cid = int(cid) - except: abort(400) - c = get_comment(cid) sub = c.post.sub if not sub: abort(400) diff --git a/files/routes/users.py b/files/routes/users.py index d7fe29e193..fd2cbb29f5 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -458,8 +458,7 @@ def suicide(v, username): @auth_required def get_coins(v, username): user = get_user(username, v=v, include_shadowbanned=False) - if user != None: return {"coins": user.coins}, 200 - else: return {"error": "invalid_user"}, 404 + return {"coins": user.coins} @app.post("/@/transfer_coins") @limiter.limit("1/second;30/minute;200/hour;1000/day") @@ -468,8 +467,6 @@ def get_coins(v, username): def transfer_coins(v, username): receiver = get_user(username, v=v, include_shadowbanned=False) - if receiver is None: return {"error": "This user doesn't exist."}, 404 - if receiver.id != v.id: amount = request.values.get("amount", "").strip() amount = int(amount) if amount.isdigit() else None @@ -512,9 +509,7 @@ def transfer_coins(v, username): @is_not_permabanned def transfer_bux(v, username): receiver = get_user(username, v=v, include_shadowbanned=False) - - if not receiver: return {"error": "This user doesn't exist."}, 404 - + if receiver.id != v.id: amount = request.values.get("amount", "").strip() amount = int(amount) if amount.isdigit() else None diff --git a/files/routes/votes.py b/files/routes/votes.py index 513f3572f2..caba2ee9c0 100644 --- a/files/routes/votes.py +++ b/files/routes/votes.py @@ -133,10 +133,6 @@ def vote_comment(comment_id, new, v): if request.headers.get("Authorization") and v.id != BBBB_ID: abort(403) new = int(new) - - try: comment_id = int(comment_id) - except: abort(404) - comment = get_comment(comment_id) coin_delta = 1 diff --git a/files/templates/userpage.html b/files/templates/userpage.html index ce56d13aed..fea1071df4 100644 --- a/files/templates/userpage.html +++ b/files/templates/userpage.html @@ -440,7 +440,7 @@ {% if u.unban_utc %}
{{u.unban_string}}
{% endif %} {% endif %} - {% if u.shadowbanned %} + {% if v and v.admin_level >= 2 and u.shadowbanned %}
SHADOWBANNED USER{% if u.ban_reason %}: {{u.ban_reason | safe}}{% endif %} (by @{{u.shadowbanned}})
{% endif %} diff --git a/seed-db.sql b/seed-db.sql index 53cfbd736f..6be4e0db02 100644 --- a/seed-db.sql +++ b/seed-db.sql @@ -1261,6 +1261,7 @@ INSERT INTO public.marseys (name, author_id, tags, created_utc) VALUES ('marseychonker2',2,'fat obese pig disgusting fatty fattie',NULL), ('marseychonkerbutch',2,'fat obese brap bitch dyke dangerhair lesbian',NULL), ('marseychonkerfoid',2,'female woman fds fat obese hambeast landwhale porker pig bleeder birthing person bangs',NULL), +('marseychonkerfoidpuke',2,'fat huge sick yuck eat barf',1664574968), ('marseychristmas',2,'candy cane santa christmas holiday',NULL), ('marseychristmasbulb',2,'ornament christmas happy holiday china',NULL), ('marseychristmasbulb2',2,'ornament holiday christmas',NULL),