diff options
author | 2024-07-07 02:29:26 +0100 | |
---|---|---|
committer | 2024-07-08 15:00:10 +0100 | |
commit | d0e09d2ba567f23d91ac76d1844966bafb9b063a (patch) | |
tree | 9e825e3f09df02ab32e401c7e9555df26356dd4c /backend/routes/discord.py | |
parent | Change linting config to Ruff (diff) |
Apply fixable lint settings with Ruff
Diffstat (limited to 'backend/routes/discord.py')
-rw-r--r-- | backend/routes/discord.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/backend/routes/discord.py b/backend/routes/discord.py index bca1edb..53b8af3 100644 --- a/backend/routes/discord.py +++ b/backend/routes/discord.py @@ -10,7 +10,8 @@ from backend import discord, models, route from backend.validation import ErrorMessage, api NOT_FOUND_EXCEPTION = JSONResponse( - {"error": "Could not find the requested resource in the guild or cache."}, status_code=404 + {"error": "Could not find the requested resource in the guild or cache."}, + status_code=404, ) @@ -28,7 +29,7 @@ class RolesRoute(route.Route): @requires(["authenticated", "admin"]) @api.validate( resp=Response(HTTP_200=RolesResponse), - tags=["roles"] + tags=["roles"], ) async def patch(self, request: Request) -> JSONResponse: """Refresh the roles database.""" @@ -54,7 +55,7 @@ class MemberRoute(route.Route): @api.validate( resp=Response(HTTP_200=models.DiscordMember, HTTP_400=ErrorMessage), json=MemberRequest, - tags=["auth"] + tags=["auth"], ) async def delete(self, request: Request) -> JSONResponse: """Force a resync of the cache for the given user.""" @@ -63,21 +64,20 @@ class MemberRoute(route.Route): if member: return JSONResponse(member.dict()) - else: - return NOT_FOUND_EXCEPTION + return NOT_FOUND_EXCEPTION @requires(["authenticated", "admin"]) @api.validate( resp=Response(HTTP_200=models.DiscordMember, HTTP_400=ErrorMessage), json=MemberRequest, - tags=["auth"] + tags=["auth"], ) async def get(self, request: Request) -> JSONResponse: """Get a user's roles on the configured server.""" body = await request.json() member = await discord.get_member(request.state.db, body["user_id"]) - if member: - return JSONResponse(member.dict()) - else: + if not member: return NOT_FOUND_EXCEPTION + + return JSONResponse(member.dict()) |