diff --git a/files/routes/admin.py b/files/routes/admin.py index a8ff4c576..8a1970f86 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -1014,7 +1014,7 @@ def api_sticky_post(post_id, v): post = g.db.query(Submission).filter_by(id=post_id).first() if post: if post.stickied: - if post.stickied.startswith("t:"): abort(403) + if post.stickied.startswith("t:"): return {"error": "Can't unpin temporary pins!"}, 403 else: post.stickied = None else: pins = g.db.query(Submission.id).filter(Submission.stickied != None, Submission.is_banned == False).count() diff --git a/files/routes/users.py b/files/routes/users.py index 102250885..96775f77c 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -253,6 +253,35 @@ def transfer_coins(v, username): return {"message": f"You can't transfer {app.config['COINS_NAME']} to yourself!"}, 400 +@app.post("/@/transfer_bux") +@limiter.limit("1/second") +@is_not_banned +@validate_formkey +def transfer_coins(v, username): + receiver = g.db.query(User).filter_by(username=username).first() + + if not receiver: return {"error": "That user doesn't exist."}, 404 + + if receiver.id != v.id: + amount = request.values.get("amount", "").strip() + amount = int(amount) if amount.isdigit() else None + + if not amount or amount < 0: return {"error": f"Invalid amount of marseybux."}, 400 + if v.procoins < amount: return {"error": f"You don't have enough marseybux"}, 400 + if amount < 100: return {"error": f"You have to gift at least 100 marseybux."}, 400 + + receiver.procoins += amount + v.procoins -= amount + send_repeatable_notification(receiver.id, f"🤑 [@{v.username}]({v.url}) has gifted you {amount} marseybux!") + g.db.add(receiver) + g.db.add(v) + + g.db.commit() + return {"message": f"{amount} marseybux transferred!"}, 200 + + return {"message": f"You can't transfer marseybux to yourself!"}, 400 + + @app.get("/leaderboard") @auth_desired def leaderboard(v): diff --git a/files/templates/header.html b/files/templates/header.html index 162914f74..b7a0131a6 100644 --- a/files/templates/header.html +++ b/files/templates/header.html @@ -98,7 +98,7 @@
{{v.username}}
{{v.coins}} {{'COINS_NAME' | app_config}}
- {% if v.procoins %}
{{v.procoins}} Marseybux
{% endif %} + {% if v.procoins %}
{{v.procoins}} Marseybux
{% endif %}
diff --git a/files/templates/userpage.html b/files/templates/userpage.html index 31493979d..59b7f40ac 100644 --- a/files/templates/userpage.html +++ b/files/templates/userpage.html @@ -190,6 +190,12 @@ +
+ +
{{u.username}} will receive 0 marseybux
+ +
+ {% elif v and v.id == u.id %} Edit profile Profile views @@ -470,6 +476,13 @@
{{u.username}} will receive 0 {{'COINS_NAME' | app_config}}
+ +
+ +
{{u.username}} will receive 0 marseybux
+ +
+ {% if v.admin_level > 1 %} @@ -677,7 +690,7 @@ {% if v %}
{% if v.patron or u.patron %}0{% else %}0.03{% endif %}
- +
{{u.username}}
{% endif %} diff --git a/files/templates/userpage_comments.html b/files/templates/userpage_comments.html index 05129dcf7..a80531d20 100644 --- a/files/templates/userpage_comments.html +++ b/files/templates/userpage_comments.html @@ -110,7 +110,7 @@ {% if v %}
{% if v.patron or u.patron %}0{% else %}0.03{% endif %}
- +
{{u.username}}
{% endif %} diff --git a/files/templates/userpage_private.html b/files/templates/userpage_private.html index 41a90b3c8..8b4e57326 100644 --- a/files/templates/userpage_private.html +++ b/files/templates/userpage_private.html @@ -35,12 +35,6 @@
{{u.id}}
{% endif %} -{% if v %} -
{% if v.patron or u.patron %}0{% else %}0.03{% endif %}
- -
{{u.username}}
-{% endif %} - {% endblock %} @@ -51,7 +45,7 @@ {% if v %}
{% if v.patron or u.patron %}0{% else %}0.03{% endif %}
- +
{{u.username}}
{% endif %}