Skip to content
Snippets Groups Projects
Commit dfecf4ac authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Refactor:Move prop includeNotificationSettingsLink up to VIPSMessage

parent 64f05652
No related branches found
No related tags found
1 merge request!34Refactor:Move prop includeNotificationSettingsLink up to VIPSMessage
This commit is part of merge request !34. Comments created here will be created in the context of that merge request.
...@@ -51,9 +51,6 @@ public class MsgToSend { ...@@ -51,9 +51,6 @@ public class MsgToSend {
// The lead paragraph (AKA "Ingress") // The lead paragraph (AKA "Ingress")
public String msgLeadParagraph; public String msgLeadParagraph;
// Include by default. If not needed, use constructor that makes it configurable
private Boolean includeNotificationSettingsLink = Boolean.TRUE;
/* (non-Javadoc) /* (non-Javadoc)
* @see no.nibio.vips_msg_dist.dao.Test#getMsgSubject() * @see no.nibio.vips_msg_dist.dao.Test#getMsgSubject()
...@@ -125,6 +122,7 @@ public class MsgToSend { ...@@ -125,6 +122,7 @@ public class MsgToSend {
this.locale = locale; this.locale = locale;
} }
/** /**
* @return The localized string **template** for generating a link to a user's page for * @return The localized string **template** for generating a link to a user's page for
* managing notification subscription settings * managing notification subscription settings
...@@ -137,17 +135,4 @@ public class MsgToSend { ...@@ -137,17 +135,4 @@ public class MsgToSend {
} }
/**
* If true, the SMS and mail messages will have this type of link appended at the end:
* "To edit your notification subscriptions, please use this link: https://logic.vips.nibio.no/user/notificationsubscription?userId=1"
* The server name can be configured with the system properties no.nibio.vips.logic.VIPSLOGIC_PROTOCOL and no.nibio.vips.logic.SERVER_NAME
* @return
*/
public Boolean getIncludeNotificationSettingsLink() {
return includeNotificationSettingsLink;
}
public void setIncludeNotificationSettingsLink(Boolean includeNotificationSettingsLink) {
this.includeNotificationSettingsLink = includeNotificationSettingsLink;
}
} }
...@@ -20,12 +20,17 @@ package no.nibio.vips.logic.messaging.distribution.entity; ...@@ -20,12 +20,17 @@ package no.nibio.vips.logic.messaging.distribution.entity;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.ResourceBundle;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.ibm.icu.util.ULocale;
import no.nibio.vips.logic.messaging.UniversalMessage; import no.nibio.vips.logic.messaging.UniversalMessage;
import no.nibio.vips.logic.messaging.distribution.send.IMsgContent; import no.nibio.vips.logic.messaging.distribution.send.IMsgContent;
import no.nibio.vips.logic.util.Globals;
/** /**
...@@ -38,7 +43,10 @@ import no.nibio.vips.logic.messaging.distribution.send.IMsgContent; ...@@ -38,7 +43,10 @@ import no.nibio.vips.logic.messaging.distribution.send.IMsgContent;
// TODO use get and setter // TODO use get and setter
public class VipsMessage implements IMsgContent { public class VipsMessage implements IMsgContent {
// Include by default. If not needed, use constructor that makes it configurable
private Boolean includeNotificationSettingsLink = Boolean.TRUE;
/** /**
* Create from UniversalMessage * Create from UniversalMessage
* TODO: Complete integration of entities! * TODO: Complete integration of entities!
...@@ -47,6 +55,7 @@ public class VipsMessage implements IMsgContent { ...@@ -47,6 +55,7 @@ public class VipsMessage implements IMsgContent {
public VipsMessage(UniversalMessage universalMessage) public VipsMessage(UniversalMessage universalMessage)
{ {
this.expiresAt = universalMessage.getExpiresAt(); this.expiresAt = universalMessage.getExpiresAt();
this.setIncludeNotificationSettingsLink(universalMessage.getIncludeNotificationSettingsLink());
this.distributionList = universalMessage.getDistributionListObjects().stream().map(umRecipient->{ this.distributionList = universalMessage.getDistributionListObjects().stream().map(umRecipient->{
MsgReceiver msgReceiver = new MsgReceiver(); MsgReceiver msgReceiver = new MsgReceiver();
msgReceiver.type = umRecipient.getType().toLowerCase().equals("mail") ? DistributionTypeEnum.Mail : DistributionTypeEnum.Sms; msgReceiver.type = umRecipient.getType().toLowerCase().equals("mail") ? DistributionTypeEnum.Mail : DistributionTypeEnum.Sms;
...@@ -102,6 +111,20 @@ public class VipsMessage implements IMsgContent { ...@@ -102,6 +111,20 @@ public class VipsMessage implements IMsgContent {
public void setMessageLocalVersions(List<MsgToSend> messageLocalVersions) { public void setMessageLocalVersions(List<MsgToSend> messageLocalVersions) {
this.messageLocalVersions = messageLocalVersions; this.messageLocalVersions = messageLocalVersions;
} }
/**
* If true, the SMS and mail messages will have this type of link appended at the end:
* "To edit your notification subscriptions, please use this link: https://logic.vips.nibio.no/user/notificationsubscription?userId=1"
* The server name can be configured with the system properties no.nibio.vips.logic.VIPSLOGIC_PROTOCOL and no.nibio.vips.logic.SERVER_NAME
* @return
*/
public Boolean getIncludeNotificationSettingsLink() {
return includeNotificationSettingsLink;
}
public void setIncludeNotificationSettingsLink(Boolean includeNotificationSettingsLink) {
this.includeNotificationSettingsLink = includeNotificationSettingsLink;
}
} }
...@@ -150,7 +150,7 @@ public class MailMsgDeliveryHandler implements IDeliveryMsgHandler { ...@@ -150,7 +150,7 @@ public class MailMsgDeliveryHandler implements IDeliveryMsgHandler {
} else { } else {
sendMessage(msgToSend.getMsgSubject(), msgToSend.getMsgLeadParagraph(), new StringBuffer(msgToSend.getMsgBody()).append("\n\n") sendMessage(msgToSend.getMsgSubject(), msgToSend.getMsgLeadParagraph(), new StringBuffer(msgToSend.getMsgBody()).append("\n\n")
.append(msgToSend.getMsgDownloadUrl() != null ? msgToSend.getMsgDownloadUrl():"") .append(msgToSend.getMsgDownloadUrl() != null ? msgToSend.getMsgDownloadUrl():"")
.append(msgToSend.getIncludeNotificationSettingsLink() ? "\n\n" + MessageFormat.format(msgToSend.getNotificationSettingsLinkTpl(),msgReceiver.recipientId): "\n"), .append(vm.getIncludeNotificationSettingsLink() ? "\n\n" + MessageFormat.format(msgToSend.getNotificationSettingsLinkTpl(),msgReceiver.recipientId): "\n"),
msgReceiver.msgDeliveryAddress); msgReceiver.msgDeliveryAddress);
} }
return SingleMsgSentStateEnum.Ok; return SingleMsgSentStateEnum.Ok;
......
...@@ -136,7 +136,7 @@ public class SmsMsgDeliveryHandler implements IDeliveryMsgHandler { ...@@ -136,7 +136,7 @@ public class SmsMsgDeliveryHandler implements IDeliveryMsgHandler {
+ msgToSend.getMsgLeadParagraph() + "\n" + msgToSend.getMsgLeadParagraph() + "\n"
+ msgToSend.getMsgBody() + msgToSend.getMsgBody()
+ (msgToSend.getMsgDownloadUrl() != null ? "\n" + msgToSend.getMsgDownloadUrl().toString(): "\n") + (msgToSend.getMsgDownloadUrl() != null ? "\n" + msgToSend.getMsgDownloadUrl().toString(): "\n")
+ (msgToSend.getIncludeNotificationSettingsLink() ? "\n\n" + MessageFormat.format(msgToSend.getNotificationSettingsLinkTpl(), msgReceiver.recipientId): "\n"); + (vm.getIncludeNotificationSettingsLink() ? "\n\n" + MessageFormat.format(msgToSend.getNotificationSettingsLinkTpl(), msgReceiver.recipientId): "\n");
LOGGER.debug(smsText); LOGGER.debug(smsText);
LOGGER.debug("Teksten er på " + smsText.length() + " tegn."); LOGGER.debug("Teksten er på " + smsText.length() + " tegn.");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment