Skip to content

Commit

Permalink
Return status 404 if target channel doesn't exist
Browse files Browse the repository at this point in the history
See also: #7
  • Loading branch information
BECATRUE committed Nov 21, 2024
1 parent 84e145c commit 4289803
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion wlm_server/operation/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ def get_running_status(ch: int) -> tuple[bool, bool]:
@api_view(['POST'])
def handle_info(request, ch: int):
user = request.user
channel = Channel.objects.get(channel=ch)
try:
channel = Channel.objects.get(channel=ch)
except Channel.DoesNotExist:
return HttpResponse(status=404)
if not channel.teams.contains(user.team):
return HttpResponse(status=403)
message_queue: MessageQueue = settings.MESSAGE_QUEUE
Expand Down
5 changes: 4 additions & 1 deletion wlm_server/setting/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
@api_view(['POST'])
def handle_info(request, ch: int):
user = request.user
channel = Channel.objects.get(channel=ch)
try:
channel = Channel.objects.get(channel=ch)
except Channel.DoesNotExist:
return HttpResponse(status=404)
if user.team not in channel.teams.all():
return HttpResponse(status=403)
message_queue: MessageQueue = settings.MESSAGE_QUEUE
Expand Down

0 comments on commit 4289803

Please sign in to comment.