From 5df9ad63cf6f13cdf21b21e5fadd335f68937856 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 16 Apr 2021 23:46:03 +0200 Subject: [PATCH] root: base Websocket message storage on Base not fallback Signed-off-by: Jens Langhammer --- authentik/root/messages/storage.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/authentik/root/messages/storage.py b/authentik/root/messages/storage.py index 4e23ca729..e9204527e 100644 --- a/authentik/root/messages/storage.py +++ b/authentik/root/messages/storage.py @@ -1,13 +1,12 @@ """Channels Messages storage""" from asgiref.sync import async_to_sync from channels.layers import get_channel_layer -from django.contrib.messages.storage.base import Message -from django.contrib.messages.storage.fallback import FallbackStorage +from django.contrib.messages.storage.base import BaseStorage, Message from django.core.cache import cache from django.http.request import HttpRequest -class ChannelsStorage(FallbackStorage): +class ChannelsStorage(BaseStorage): """Send contrib.messages over websocket""" def __init__(self, request: HttpRequest) -> None: @@ -15,6 +14,9 @@ class ChannelsStorage(FallbackStorage): super().__init__(request) self.channel = get_channel_layer() + def _get(self): + return [], True + def _store(self, messages: list[Message], response, *args, **kwargs): prefix = f"user_{self.request.session.session_key}_messages_" keys = cache.keys(f"{prefix}*")