From c3c8cbf7efeb6a50b87867d2ed781e7d6c0292c5 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 28 Aug 2022 15:39:42 +0200 Subject: [PATCH] events: save event to test notification transport closes #3485 Signed-off-by: Jens Langhammer --- authentik/events/api/notification_transports.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/authentik/events/api/notification_transports.py b/authentik/events/api/notification_transports.py index 611fa9a5c..7eae95f26 100644 --- a/authentik/events/api/notification_transports.py +++ b/authentik/events/api/notification_transports.py @@ -85,16 +85,18 @@ class NotificationTransportViewSet(UsedByMixin, ModelViewSet): """Send example notification using selected transport. Requires Modify permissions.""" transport: NotificationTransport = self.get_object() + event = Event.new( + action="notification_test", + user=get_user(request.user), + app=self.__class__.__module__, + context={"foo": "bar"}, + ) + event.save() notification = Notification( severity=NotificationSeverity.NOTICE, body=f"Test Notification from transport {transport.name}", user=request.user, - event=Event( - action="Test", - user=get_user(request.user), - app=self.__class__.__module__, - context={"foo": "bar"}, - ), + event=event, ) try: response = NotificationTransportTestSerializer(