Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Minor notification improvements

Rich Turnerd0e76eb4e74c
diff --git a/manager/src/main/java/org/openremote/manager/notification/EmailNotificationHandler.java b/manager/src/main/java/org/openremote/manager/notification/EmailNotificationHandler.java
index f54ee5695..e389614a8 100644
--- a/manager/src/main/java/org/openremote/manager/notification/EmailNotificationHandler.java
+++ b/manager/src/main/java/org/openremote/manager/notification/EmailNotificationHandler.java
@@ -229,7 +229,7 @@ public class EmailNotificationHandler implements NotificationHandler {
.map(recipient ->
new Notification.Target(Notification.TargetType.CUSTOM, recipient.getAddress()))
.collect(Collectors.toList()));
- email.setTo((String) null);
+ email.setTo((List<EmailNotificationMessage.Recipient>) null);
}
if (email.getCc() != null) {
mappedTargets.addAll(
@@ -237,7 +237,7 @@ public class EmailNotificationHandler implements NotificationHandler {
.map(recipient ->
new Notification.Target(Notification.TargetType.CUSTOM, recipient.getAddress()))
.collect(Collectors.toList()));
- email.setCc((String) null);
+ email.setCc((List<EmailNotificationMessage.Recipient>) null);
}
if (email.getBcc() != null) {
mappedTargets.addAll(
@@ -245,7 +245,7 @@ public class EmailNotificationHandler implements NotificationHandler {
.map(recipient ->
new Notification.Target(Notification.TargetType.CUSTOM, recipient.getAddress()))
.collect(Collectors.toList()));
- email.setBcc((String) null);
+ email.setBcc((List<EmailNotificationMessage.Recipient>) null);
}
return mappedTargets;
@@ -273,7 +273,8 @@ public class EmailNotificationHandler implements NotificationHandler {
recipient = getAssetRecipient(targetId);
break;
case CUSTOM:
- // This recipient is in the message already
+ // This recipient is the target ID
+ recipient = new EmailNotificationMessage.Recipient(targetId);
break;
default:
LOG.warning("Target type not supported: " + targetType);
diff --git a/manager/src/main/java/org/openremote/manager/notification/NotificationService.java b/manager/src/main/java/org/openremote/manager/notification/NotificationService.java
index bd00ac4d8..03cf46697 100644
--- a/manager/src/main/java/org/openremote/manager/notification/NotificationService.java
+++ b/manager/src/main/java/org/openremote/manager/notification/NotificationService.java
@@ -249,6 +249,7 @@ public class NotificationService extends RouteBuilder implements ContainerServic
.setSourceId(sourceId.get())
.setTarget(target.getType())
.setTargetId(target.getId())
+ .setMessage(notification.getMessage().toValue())
.setSentOn(Date.from(timerService.getNow()));
sentNotification = em.merge(sentNotification);
@@ -277,7 +278,6 @@ public class NotificationService extends RouteBuilder implements ContainerServic
e);
sentNotification.setError(TextUtil.isNullOrEmpty(e.getMessage()) ? "Unknown error" : e.getMessage());
em.merge(sentNotification);
- throw e;
}
})
);