authentik.enterprise.requests.tasks
PAM access-request notification tasks
1"""PAM access-request notification tasks""" 2 3from uuid import UUID 4 5from django.utils.translation import gettext_lazy as _ 6from dramatiq.actor import actor 7 8from authentik.core.models import User 9from authentik.events.models import Event, Notification, NotificationSeverity, NotificationTransport 10 11 12@actor(description=_("Send access-request review notification.")) 13def requests_send_request_notification(transport_pk: UUID, event_pk: UUID, user_pk: int): 14 """Send a single review notification over the given transport, to the given user""" 15 event = Event.objects.filter(pk=event_pk).first() 16 if not event: 17 return 18 user = User.objects.filter(pk=user_pk).first() 19 if not user: 20 return 21 transport = NotificationTransport.objects.filter(pk=transport_pk).first() 22 if not transport: 23 return 24 notification = Notification( 25 severity=NotificationSeverity.NOTICE, 26 body=event.summary, 27 event=event, 28 user=user, 29 hyperlink=event.hyperlink, 30 hyperlink_label=event.hyperlink_label, 31 ) 32 transport.send(notification)
requests_send_request_notification =
Actor(<function requests_send_request_notification>, queue_name='default', actor_name='requests_send_request_notification')
Send a single review notification over the given transport, to the given user