From f02b25f15a55506040e0d5b082ba9528f28c2948 Mon Sep 17 00:00:00 2001 From: ViacheslavKlimov Date: Mon, 30 Dec 2024 16:15:37 +0200 Subject: [PATCH] Ignore unconfigured delivery method for system notification type --- .../service/notification/DefaultNotificationCenter.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/service/notification/DefaultNotificationCenter.java b/application/src/main/java/org/thingsboard/server/service/notification/DefaultNotificationCenter.java index 9a293ada7e..685311c477 100644 --- a/application/src/main/java/org/thingsboard/server/service/notification/DefaultNotificationCenter.java +++ b/application/src/main/java/org/thingsboard/server/service/notification/DefaultNotificationCenter.java @@ -122,6 +122,7 @@ public class DefaultNotificationCenter extends AbstractSubscriptionService imple if (notificationTemplate == null) { throw new IllegalArgumentException("Template is missing"); } + NotificationType notificationType = notificationTemplate.getNotificationType(); Set deliveryMethods = new HashSet<>(); List targets = new ArrayList<>(); @@ -143,13 +144,13 @@ public class DefaultNotificationCenter extends AbstractSubscriptionService imple try { channels.get(deliveryMethod).check(tenantId); } catch (Exception e) { - if (ruleId == null) { + if (ruleId == null && !notificationType.isSystem()) { throw new IllegalArgumentException(e.getMessage()); } else { - return; // if originated by rule - just ignore delivery method + return; // if originated by rule or notification type is system - just ignore delivery method } } - if (ruleId == null && !notificationTemplate.getNotificationType().isSystem()) { + if (ruleId == null && !notificationType.isSystem()) { if (targets.stream().noneMatch(target -> target.getConfiguration().getType().getSupportedDeliveryMethods().contains(deliveryMethod))) { throw new IllegalArgumentException("Recipients for " + deliveryMethod.getName() + " delivery method not chosen"); }