|
|
|
@ -73,6 +73,7 @@ import org.thingsboard.server.service.telemetry.AbstractSubscriptionService; |
|
|
|
import org.thingsboard.server.service.ws.notification.sub.NotificationRequestUpdate; |
|
|
|
import org.thingsboard.server.service.ws.notification.sub.NotificationUpdate; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.HashSet; |
|
|
|
import java.util.List; |
|
|
|
@ -115,12 +116,23 @@ public class DefaultNotificationCenter extends AbstractSubscriptionService imple |
|
|
|
} else { |
|
|
|
notificationTemplate = request.getTemplate(); |
|
|
|
} |
|
|
|
if (notificationTemplate == null) throw new IllegalArgumentException("Template is missing"); |
|
|
|
if (notificationTemplate == null) { |
|
|
|
throw new IllegalArgumentException("Template is missing"); |
|
|
|
} |
|
|
|
|
|
|
|
Set<NotificationDeliveryMethod> deliveryMethods = new HashSet<>(); |
|
|
|
List<NotificationTarget> targets = request.getTargets().stream().map(NotificationTargetId::new) |
|
|
|
.map(id -> notificationTargetService.findNotificationTargetById(tenantId, id)) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
List<NotificationTarget> targets = new ArrayList<>(); |
|
|
|
for (UUID targetId : request.getTargets()) { |
|
|
|
NotificationTarget target = notificationTargetService.findNotificationTargetById(tenantId, new NotificationTargetId(targetId)); |
|
|
|
if (target != null) { |
|
|
|
targets.add(target); |
|
|
|
} else { |
|
|
|
log.debug("Unknown notification target {} in request {}", targetId, request); |
|
|
|
} |
|
|
|
} |
|
|
|
if (targets.isEmpty()) { |
|
|
|
throw new IllegalArgumentException("No recipients chosen"); |
|
|
|
} |
|
|
|
|
|
|
|
NotificationRuleId ruleId = request.getRuleId(); |
|
|
|
notificationTemplate.getConfiguration().getDeliveryMethodsTemplates().forEach((deliveryMethod, template) -> { |
|
|
|
|