diff --git a/InvenTree/common/notifications.py b/InvenTree/common/notifications.py index bae6f6a763..86b9a922b1 100644 --- a/InvenTree/common/notifications.py +++ b/InvenTree/common/notifications.py @@ -7,7 +7,7 @@ from django.template.loader import render_to_string from allauth.account.models import EmailAddress from InvenTree.helpers import inheritors -from common.models import NotificationEntry +from common.models import NotificationEntry, NotificationMessage import InvenTree.tasks @@ -82,6 +82,22 @@ class EmailNotification(BulkNotificationMethod): InvenTree.tasks.send_email(context['template']['subject'], '', recipients, html_message=html_message) return True + +class UIMessageNotification(SingleNotificationMethod): + METHOD_NAME = 'ui_message' + + def get_recipients(self): + return self.receivers + + def send(self, receiver, context): + NotificationMessage.objects.create( + target_object = self.obj, + source_object = receiver, + user = receiver, + category = self.entry_name, + name = context['name'], + message = context['message'], + ) # endregion # endregion