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

Merge branch 'feat/add-user-subscription-link-vipsutv-342' into 'develop'

Refactor:Move prop includeNotificationSettingsLink up to VIPSMessage

See merge request !34
parents baaf1c43 dfecf4ac
No related branches found
No related tags found
1 merge request!34Refactor:Move prop includeNotificationSettingsLink up to VIPSMessage
......@@ -51,9 +51,6 @@ public class MsgToSend {
// The lead paragraph (AKA "Ingress")
public String msgLeadParagraph;
// Include by default. If not needed, use constructor that makes it configurable
private Boolean includeNotificationSettingsLink = Boolean.TRUE;
/* (non-Javadoc)
* @see no.nibio.vips_msg_dist.dao.Test#getMsgSubject()
......@@ -125,6 +122,7 @@ public class MsgToSend {
this.locale = locale;
}
/**
* @return The localized string **template** for generating a link to a user's page for
* managing notification subscription settings
......@@ -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;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.ResourceBundle;
import java.util.stream.Collectors;
import com.ibm.icu.util.ULocale;
import no.nibio.vips.logic.messaging.UniversalMessage;
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;
// TODO use get and setter
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
* TODO: Complete integration of entities!
......@@ -47,6 +55,7 @@ public class VipsMessage implements IMsgContent {
public VipsMessage(UniversalMessage universalMessage)
{
this.expiresAt = universalMessage.getExpiresAt();
this.setIncludeNotificationSettingsLink(universalMessage.getIncludeNotificationSettingsLink());
this.distributionList = universalMessage.getDistributionListObjects().stream().map(umRecipient->{
MsgReceiver msgReceiver = new MsgReceiver();
msgReceiver.type = umRecipient.getType().toLowerCase().equals("mail") ? DistributionTypeEnum.Mail : DistributionTypeEnum.Sms;
......@@ -102,6 +111,20 @@ public class VipsMessage implements IMsgContent {
public void setMessageLocalVersions(List<MsgToSend> 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 {
} else {
sendMessage(msgToSend.getMsgSubject(), msgToSend.getMsgLeadParagraph(), new StringBuffer(msgToSend.getMsgBody()).append("\n\n")
.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);
}
return SingleMsgSentStateEnum.Ok;
......
......@@ -136,7 +136,7 @@ public class SmsMsgDeliveryHandler implements IDeliveryMsgHandler {
+ msgToSend.getMsgLeadParagraph() + "\n"
+ msgToSend.getMsgBody()
+ (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("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