events: only create SYSTEM_EXCEPTION event when error would've been sent to sentry
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
eaaeaccf5d
commit
6930c84425
|
@ -13,6 +13,7 @@ from authentik.core.models import User
|
||||||
from authentik.events.models import Event, EventAction, Notification
|
from authentik.events.models import Event, EventAction, Notification
|
||||||
from authentik.events.signals import EventNewThread
|
from authentik.events.signals import EventNewThread
|
||||||
from authentik.events.utils import model_to_dict
|
from authentik.events.utils import model_to_dict
|
||||||
|
from authentik.lib.sentry import before_send
|
||||||
from authentik.lib.utils.errors import exception_to_string
|
from authentik.lib.utils.errors import exception_to_string
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,12 +63,13 @@ class AuditMiddleware:
|
||||||
|
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
return
|
return
|
||||||
thread = EventNewThread(
|
if before_send({}, {"exc_info": (None, exception, None)}) is not None:
|
||||||
EventAction.SYSTEM_EXCEPTION,
|
thread = EventNewThread(
|
||||||
request,
|
EventAction.SYSTEM_EXCEPTION,
|
||||||
message=exception_to_string(exception),
|
request,
|
||||||
)
|
message=exception_to_string(exception),
|
||||||
thread.run()
|
)
|
||||||
|
thread.run()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
|
|
Reference in a new issue