Skip to content

Commit

Permalink
file path fixes for osu redirects (osuAkatsuki#550)
Browse files Browse the repository at this point in the history
* file path fixes for osu redirects

* undo changes
  • Loading branch information
cmyui committed Dec 1, 2023
1 parent 3ccce28 commit bb1c160
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
1 change: 0 additions & 1 deletion app/api/domains/cho.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@

BASE_DOMAIN = app.settings.DOMAIN

# TODO: dear god
NOW_PLAYING_RGX = re.compile(
r"^\x01ACTION is (?:playing|editing|watching|listening to) "
rf"\[https://osu\.(?:{re.escape(BASE_DOMAIN)}|ppy\.sh)/beatmapsets/(?P<sid>\d{{1,10}})#/?(?:osu|taiko|fruits|mania)?/(?P<bid>\d{{1,10}})/? .+\]"
Expand Down
13 changes: 6 additions & 7 deletions app/api/domains/osu.py
Original file line number Diff line number Diff line change
Expand Up @@ -1723,18 +1723,17 @@ async def checkUpdates(


if app.settings.REDIRECT_OSU_URLS:
# NOTE: this will likely be removed with the addition of a frontend.
async def osu_redirect(request: Request, _: int = Path(...)) -> Response:

async def osu_redirect(file_path: str) -> Response:
return RedirectResponse(
url=f"https://osu.ppy.sh{request['path']}",
url=f"https://osu.ppy.sh{file_path}",
status_code=status.HTTP_301_MOVED_PERMANENTLY,
)

for pattern in (
"/beatmapsets/{_}",
"/beatmaps/{_}",
"/beatmapsets/{_}/discussion",
"/community/forums/topics/{_}",
"/beatmapsets/{file_path:path}",
"/beatmaps/{file_path:path}",
"/community/forums/topics/{file_path:path}",
):
router.get(pattern)(osu_redirect)

Expand Down

0 comments on commit bb1c160

Please sign in to comment.