events: don't create system exception event in debug
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
f10bd432b3
commit
ec4c3f44cb
|
@ -2,6 +2,7 @@
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
from django.db.models import Model
|
from django.db.models import Model
|
||||||
from django.db.models.signals import post_save, pre_delete
|
from django.db.models.signals import post_save, pre_delete
|
||||||
from django.http import HttpRequest, HttpResponse
|
from django.http import HttpRequest, HttpResponse
|
||||||
|
@ -56,6 +57,11 @@ class AuditMiddleware:
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
def process_exception(self, request: HttpRequest, exception: Exception):
|
def process_exception(self, request: HttpRequest, exception: Exception):
|
||||||
"""Disconnect handlers in case of exception"""
|
"""Disconnect handlers in case of exception"""
|
||||||
|
post_save.disconnect(dispatch_uid=LOCAL.authentik["request_id"])
|
||||||
|
pre_delete.disconnect(dispatch_uid=LOCAL.authentik["request_id"])
|
||||||
|
|
||||||
|
if settings.DEBUG:
|
||||||
|
return
|
||||||
thread = EventNewThread(
|
thread = EventNewThread(
|
||||||
EventAction.SYSTEM_EXCEPTION,
|
EventAction.SYSTEM_EXCEPTION,
|
||||||
request,
|
request,
|
||||||
|
@ -63,9 +69,6 @@ class AuditMiddleware:
|
||||||
)
|
)
|
||||||
thread.run()
|
thread.run()
|
||||||
|
|
||||||
post_save.disconnect(dispatch_uid=LOCAL.authentik["request_id"])
|
|
||||||
pre_delete.disconnect(dispatch_uid=LOCAL.authentik["request_id"])
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
def post_save_handler(
|
def post_save_handler(
|
||||||
|
|
Reference in a new issue