ChannelsView - 404 if server not found
All checks were successful
Build and Push Docker Image / build (push) Successful in 14s

This commit is contained in:
Corban-Lee Jones 2024-10-11 10:35:03 +01:00
parent c4ce4b28a0
commit 5f0251bd87

View File

@ -1,14 +1,12 @@
# -*- encoding: utf-8 -*-
import json
import logging
import httpx
from django.conf import settings
from django.utils import timezone
from asgiref.sync import sync_to_async
from django.shortcuts import redirect
from django.http import JsonResponse, HttpResponse
from django.http import JsonResponse, HttpResponseNotFound
from django.views.generic import TemplateView, View
from django.core.exceptions import PermissionDenied
@ -109,7 +107,10 @@ class ChannelsView(View):
return redirect("/oauth2/login")
guild_id = request.GET.get("guild")
server = await Server.objects.aget(pk=guild_id)
try:
server = await Server.objects.aget(pk=guild_id)
except Server.DoesNotExist:
return HttpResponseNotFound("Server not found.")
if not ServerMember.objects.filter(server=server, user=request.user).aexists():
raise PermissionDenied("You aren't a member of this server.")