From 98cf3cd3ad5079df215785aad8052a9b0e7025d7 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 2 Dec 2021 02:52:18 +0100 Subject: [PATCH] log results of delivery --- InvenTree/common/notifications.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/InvenTree/common/notifications.py b/InvenTree/common/notifications.py index ec38570fb7..6d0e734eee 100644 --- a/InvenTree/common/notifications.py +++ b/InvenTree/common/notifications.py @@ -132,14 +132,27 @@ def deliver_notification(cls: NotificationMethod, obj, entry_name: str, receiver method = cls(obj, entry_name, receivers) if method.recipiends and method.recipiends.count() > 0: + # Log start logger.info(f"Notify users via '{method.method_name}' for notification '{entry_name}' for '{str(obj)}'") + success = True + success_count = 0 + if hasattr(method, 'send_bulk'): - method.send_bulk(notification_context) + success = method.send_bulk(notification_context) + success_count = method.recipiends.count() elif hasattr(method, 'send'): for rec in method.recipiends: - method.send(rec, notification_context) + if method.send(rec, notification_context): + success_count += 1 + else: + success = False else: raise NotImplementedError('No delivery method found') + + # Log results + logger.info(f"Notified {success_count} users via '{method.method_name}' for notification '{entry_name}' for '{str(obj)}' successfully") + if not success: + logger.info("There were some problems")