aboutsummaryrefslogtreecommitdiffstats
path: root/backend/routes/discord.py
diff options
context:
space:
mode:
authorGravatar Joe Banks <[email protected]>2024-07-08 15:09:17 +0100
committerGravatar GitHub <[email protected]>2024-07-08 15:09:17 +0100
commit642c0795c8738bf8b9ae39b9cf0180f7cdbac650 (patch)
tree4a075255d00d9f8a2f369567bdb79f6eefa4be9a /backend/routes/discord.py
parentMigration to official Sentry release CI action (#275) (diff)
parentStop using gunicorn and use uvicorn directly to run application (diff)
Merge pull request #276 from python-discord/jb3/environ/python-3.12
3.12 + Updates
Diffstat (limited to 'backend/routes/discord.py')
-rw-r--r--backend/routes/discord.py18
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())