events: set severity for default triggers

This commit is contained in:
Jens Langhammer 2021-01-14 16:51:55 +01:00
parent 9fe8554f28
commit 8beddcddb0

View file

@ -4,7 +4,7 @@ from django.apps.registry import Apps
from django.db import migrations from django.db import migrations
from django.db.backends.base.schema import BaseDatabaseSchemaEditor from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from authentik.events.models import EventAction, TransportMode from authentik.events.models import EventAction, NotificationSeverity, TransportMode
def notify_configuration_error(apps: Apps, schema_editor: BaseDatabaseSchemaEditor): def notify_configuration_error(apps: Apps, schema_editor: BaseDatabaseSchemaEditor):
@ -27,7 +27,8 @@ def notify_configuration_error(apps: Apps, schema_editor: BaseDatabaseSchemaEdit
defaults={"action": EventAction.CONFIGURATION_ERROR}, defaults={"action": EventAction.CONFIGURATION_ERROR},
) )
trigger, _ = NotificationTrigger.objects.using(db_alias).update_or_create( trigger, _ = NotificationTrigger.objects.using(db_alias).update_or_create(
name="default-notify-configuration-error", defaults={"group": admin_group} name="default-notify-configuration-error",
defaults={"group": admin_group, "severity": NotificationSeverity.ALERT},
) )
PolicyBinding.objects.using(db_alias).update_or_create( PolicyBinding.objects.using(db_alias).update_or_create(
target=trigger, target=trigger,
@ -58,7 +59,8 @@ def notify_update(apps: Apps, schema_editor: BaseDatabaseSchemaEditor):
defaults={"action": EventAction.UPDATE_AVAILABLE}, defaults={"action": EventAction.UPDATE_AVAILABLE},
) )
trigger, _ = NotificationTrigger.objects.using(db_alias).update_or_create( trigger, _ = NotificationTrigger.objects.using(db_alias).update_or_create(
name="default-notify-update", defaults={"group": admin_group} name="default-notify-update",
defaults={"group": admin_group, "severity": NotificationSeverity.ALERT},
) )
PolicyBinding.objects.using(db_alias).update_or_create( PolicyBinding.objects.using(db_alias).update_or_create(
target=trigger, target=trigger,
@ -93,7 +95,8 @@ def notify_exception(apps: Apps, schema_editor: BaseDatabaseSchemaEditor):
defaults={"action": EventAction.PROPERTY_MAPPING_EXCEPTION}, defaults={"action": EventAction.PROPERTY_MAPPING_EXCEPTION},
) )
trigger, _ = NotificationTrigger.objects.using(db_alias).update_or_create( trigger, _ = NotificationTrigger.objects.using(db_alias).update_or_create(
name="default-notify-exception", defaults={"group": admin_group} name="default-notify-exception",
defaults={"group": admin_group, "severity": NotificationSeverity.ALERT},
) )
PolicyBinding.objects.using(db_alias).update_or_create( PolicyBinding.objects.using(db_alias).update_or_create(
target=trigger, target=trigger,