diff --git a/InvenTree/common/notifications.py b/InvenTree/common/notifications.py index fbe0bd1365..1f1b743c1c 100644 --- a/InvenTree/common/notifications.py +++ b/InvenTree/common/notifications.py @@ -114,6 +114,12 @@ class NotificationMethod: # Lets go! return False + + def usersetting(self, target): + """ + Returns setting for this method for a given user + """ + return NotificationUserSetting.get_setting(f'NOTIFICATION_METHOD_{self.METHOD_NAME.upper()}', user=target, method=self.METHOD_NAME) # endregion @@ -220,7 +226,7 @@ def trigger_notifaction(obj, category=None, obj_ref='pk', **kwargs): if NotificationEntry.check_recent(category, obj_ref_value, delta): logger.info(f"Notification '{category}' has recently been sent for '{str(obj)}' - SKIPPING") - return + # return logger.info(f"Gathering users for notification '{category}'") # Collect possible targets diff --git a/InvenTree/plugin/builtin/integration/core_notifications.py b/InvenTree/plugin/builtin/integration/core_notifications.py index 3d5ce06cb6..a26c69e877 100644 --- a/InvenTree/plugin/builtin/integration/core_notifications.py +++ b/InvenTree/plugin/builtin/integration/core_notifications.py @@ -7,7 +7,6 @@ from allauth.account.models import EmailAddress from plugin import IntegrationPluginBase from plugin.mixins import BulkNotificationMethod, SettingsMixin -from plugin.models import NotificationUserSetting import InvenTree.tasks @@ -59,7 +58,7 @@ class CoreNotificationsPlugin(SettingsMixin, IntegrationPluginBase): allowed_users = [] for user in self.targets: - allows_emails = NotificationUserSetting.get_setting('NOTIFICATION_METHOD_MAIL', user=user, method=self.METHOD_NAME) + allows_emails = self.usersetting(user) if allows_emails: allowed_users.append(user)