Attempt to fix some tracebacks

This commit is contained in:
Finn Stutzenstein 2020-10-05 12:07:04 +02:00
parent 1707c1f4fd
commit f809db0430
No known key found for this signature in database
GPG Key ID: 9042F605C6324654
3 changed files with 15 additions and 0 deletions

View File

@ -432,6 +432,7 @@ class SpeakerManager(models.Manager):
"""
if isinstance(user, AnonymousUser):
raise OpenSlidesError("An anonymous user can not be on lists of speakers.")
if self.filter(
user=user, list_of_speakers=list_of_speakers, begin_time=None
).exists():

View File

@ -847,6 +847,10 @@ class WhoAmIDataView(APIView):
user_full_data = async_to_sync(element_cache.get_element_data)(
self.request.user.get_collection_string(), user_id
)
if user_full_data is None:
return Response(
{"detail": "Cache offline, could not fetch user"}, status=500
)
auth_type = user_full_data["auth_type"]
user_data = async_to_sync(element_cache.restrict_element_data)(
user_full_data, self.request.user.get_collection_string(), user_id

View File

@ -8,6 +8,7 @@ from channels.layers import get_channel_layer
from django.db.models import Model
from mypy_extensions import TypedDict
from .auth import UserDoesNotExist
from .cache import ChangeIdTooLowError, element_cache, get_element_id
from .projector import get_projector_data
from .timing import Timing
@ -303,6 +304,15 @@ class AutoupdateBundleMiddleware:
async def get_autoupdate_data(
from_change_id: int, user_id: int
) -> Tuple[int, Optional[AutoupdateFormat]]:
try:
return await _get_autoupdate_data(from_change_id, user_id)
except UserDoesNotExist:
return 0, None
async def _get_autoupdate_data(
from_change_id: int, user_id: int
) -> Tuple[int, Optional[AutoupdateFormat]]:
"""
Returns the max_change_id and the autoupdate from from_change_id to max_change_id