From 6445c0b671c6f5500da9f4ec8b2bcefbeed60ad7 Mon Sep 17 00:00:00 2001 From: Aevann Date: Fri, 1 Dec 2023 21:59:08 +0200 Subject: [PATCH] fix this https://rdrama.net/post/225644/yo-check-this-out-marseysoypoint-marseysoypoint/5476685#context --- files/routes/users.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/files/routes/users.py b/files/routes/users.py index a5df15b68..3b54084d2 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -1491,3 +1491,18 @@ def unmute_notifs(v, uid): send_notification(user.id, f"@{v.username} has unmuted notifications from you!") return {"message": f"You have unmuted notifications from @{user.username} successfully!"} + +@app.get("/@/song") +@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400) +def usersong(username): + user = get_user(username) + + if not user.song: + abort(404, f"@{user.username} hasn't set a profile anthem!") + + if len(user.song) == 11: + return redirect(f'https://youtube.com/watch?v={user.song}') + + resp = make_response(redirect(f"/songs/{user.song}.mp3")) + resp.headers["Cache-Control"] = "no-store" + return resp