diff --git a/files/assets/css/main.css b/files/assets/css/main.css index f5cec6710..ece210613 100644 --- a/files/assets/css/main.css +++ b/files/assets/css/main.css @@ -6060,7 +6060,6 @@ g { .fa-paw-simple:before{content:"\f701"} .fa-bat:before{content:"\f6b5"} .fa-star-of-david:before{content:"\f69a"} -.fa-kiss-wink-heart:before{content:"\f598"} .fa-hat-cowboy:before{content:"\f8c0"} .fa-cloud-rainbow:before{content:"\f73e"} diff --git a/files/helpers/regex.py b/files/helpers/regex.py index 5130c90a9..8e4b1abd2 100644 --- a/files/helpers/regex.py +++ b/files/helpers/regex.py @@ -12,7 +12,7 @@ marseyaward_body_regex = re.compile(">[^<\s+]|[^>\s+]<", flags=re.A) marseyaward_title_regex = re.compile("( *]+>)+", flags=re.A) -marsey_regex = re.compile("[a-z0-9]{1,30}", flags=re.A) +marsey_regex = re.compile("marsey[a-z0-9]{1,24}", flags=re.A) hat_regex = re.compile("[a-zA-Z0-9\-() ,_]{1,50}", flags=re.A) diff --git a/files/routes/casino.py b/files/routes/casino.py index ec298188a..9b6d4f769 100644 --- a/files/routes/casino.py +++ b/files/routes/casino.py @@ -13,12 +13,16 @@ from files.helpers.lottery import * @app.get("/casino") @auth_required def casino(v): + if v.rehab: return {"error": "You are under Rehab award effect!"} + participants = get_users_participating_in_lottery() return render_template("casino.html", v=v, participants=participants) @app.get("/casino/") @auth_required def casino_game_page(v, game): + if v.rehab: return {"error": "You are under Rehab award effect!"} + return render_template( f"casino/{game}_screen.html", v=v, @@ -30,6 +34,8 @@ def casino_game_page(v, game): @limiter.limit("3/second;30/minute;600/hour;12000/day") @auth_required def pull_slots(v): + if v.rehab: return {"error": "You are under Rehab award effect!"} + try: wager = int(request.values.get("wager")) except: @@ -55,6 +61,8 @@ def pull_slots(v): @limiter.limit("3/second;30/minute;600/hour;12000/day") @auth_required def get_player_blackjack_status(v): + if v.rehab: return {"error": "You are under Rehab award effect!"} + game, _, safe_state = get_active_game(v) if game: @@ -67,6 +75,8 @@ def get_player_blackjack_status(v): @limiter.limit("3/second;30/minute;600/hour;12000/day") @auth_required def player_took_blackjack_action(v): + if v.rehab: return {"error": "You are under Rehab award effect!"} + try: action = request.values.get("action") except: diff --git a/files/routes/static.py b/files/routes/static.py index 4a03a4b21..02066e919 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -454,27 +454,39 @@ def submit_marseys(v): return render_template("submit_marseys.html", v=v, marseys=marseys) -@app.post("/submit/marsey") +@app.post("/submit/marseys") @auth_required def submit_marsey(v): + if v.admin_level > 2: + marseys = g.db.query(Marsey).filter(Marsey.submitter_id != None).all() + else: + marseys = g.db.query(Marsey).filter(Marsey.submitter_id == v.id).all() + + for marsey in marseys: + marsey.author = g.db.query(User.username).filter_by(id=marsey.author_id).one()[0] + marsey.submitter = g.db.query(User.username).filter_by(id=marsey.submitter_id).one()[0] + + def error(error): + return render_template("submit_marseys.html", v=v, marseys=marseys, error=error) + if request.headers.get("cf-ipcountry") == "T1": - return {"error":"Image uploads are not allowed through TOR."} + return error("Image uploads are not allowed through TOR.") file = request.files["image"] if not file or not file.content_type.startswith('image/'): - return {"error": "You need to submit an image!"} + return error("You need to submit an image!") name = request.values.get('name').lower() if not marsey_regex.fullmatch(name): - return {"error": "Invalid name!"} + return error("Invalid name!") existing = g.db.query(Marsey.name).filter_by(name=name).one_or_none() if existing: - return {"error": "A marsey with this name already exists!"} + return error("A marsey with this name already exists!") tags = request.values.get('tags').lower() if not tags_regex.fullmatch(tags): - return {"error": "Invalid tags!"} + return error("Invalid tags!") author = request.values.get('author') author = get_user(author) @@ -486,19 +498,22 @@ def submit_marsey(v): marsey = Marsey(name=name, author_id=author.id, tags=tags, count=0, submitter_id=v.id) g.db.add(marsey) - return redirect('/submit/marseys') + return render_template("submit_marseys.html", v=v, marseys=marseys, msg=f"'{name}' submitted successfully!") @app.post("/admin/approve/marsey/") @admin_level_required(3) def approve_marsey(v, name): - if CARP_ID and v.id != CARP_ID: abort(403) + if CARP_ID and v.id != CARP_ID: + return {"error": "Only Carp can approve marseys!"} marsey = g.db.query(Marsey).filter_by(name=name).one_or_none() - if not marsey: abort(404) + if not marsey: + return {"error": f"This marsey '{name}' doesn't exist!"} tags = request.values.get('tags') - if not tags: abort(400) + if not tags: + return {"error": "You need to include tags!"} marsey.tags = tags g.db.add(marsey) @@ -528,12 +543,14 @@ def approve_marsey(v, name): @app.post("/admin/reject/marsey/") @admin_level_required(3) def reject_marsey(v, name): - if CARP_ID and v.id != CARP_ID: abort(403) + if CARP_ID and v.id != CARP_ID: + return {"error": "Only Carp can approve marseys!"} marsey = g.db.query(Marsey).filter_by(name=name).one_or_none() - if not marsey: abort(404) + if not marsey: + return {"error": f"This marsey '{name}' doesn't exist!"} - msg = f'@{v.username} has rejected a marsey you submitted: `{marsey.name}`' + msg = f"@{v.username} has rejected a marsey you submitted: '{marsey.name}'" send_repeatable_notification(marsey.submitter_id, msg) g.db.delete(marsey) diff --git a/files/routes/users.py b/files/routes/users.py index 0256a88ab..4c3591860 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -975,6 +975,7 @@ def u_username(username, v=None): else: view = ViewerRelationship(viewer_id=v.id, user_id=u.id) g.db.add(view) + g.db.commit() if u.is_private and (not v or (v.id != u.id and v.admin_level < 2 and not v.eye)): diff --git a/files/templates/chat.html b/files/templates/chat.html index 5f04f5fb0..6d5e456f2 100644 --- a/files/templates/chat.html +++ b/files/templates/chat.html @@ -197,7 +197,7 @@ - + diff --git a/files/templates/comments.html b/files/templates/comments.html index 00e113375..2671f0715 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -278,7 +278,7 @@   - +