Added support for messages reply via email

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application-support-layer/applicationSupportLayerSocial@119765 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2015-10-14 15:27:13 +00:00
parent 4b0ade3246
commit 1ef768a7de
4 changed files with 35 additions and 8 deletions

View File

@ -427,8 +427,17 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
* {@inheritDoc}
*/
@Override
public boolean notifyMessageReceived(String userIdToNotify, String messageId, String subject, String messageText) {
public boolean notifyMessageReceived(String userIdToNotify, String messageId, String subject, String messageText, String ... otherRecipientsFullNames) {
String[] optionalParams = {subject};
String otherRecipientNames = "";
if (otherRecipientsFullNames != null && otherRecipientsFullNames.length > 0) {
otherRecipientNames = "<br/><div> - This message was also sent to: <ul>";
for (int i = 0; i < otherRecipientsFullNames.length; i++) {
otherRecipientNames += "<li> " + otherRecipientsFullNames[i] + "</li>";
}
otherRecipientNames += "</ul></div><div> If you reply, your message will be also delivered to them.</div>";
}
Notification not = new Notification(
UUID.randomUUID().toString(),
NotificationType.MESSAGE,
@ -437,8 +446,9 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
new Date(),
"/group/data-e-infrastructure-gateway/messages",
"sent you a message: "
+ "<div style=\"margin-top: 10px; margin-bottom: 10px; margin-left: 50px; padding-left: 15px; border-left: 3px solid #ccc; font-style: italic;\">\""
+ escapeHtml(messageText) +"\"</div>",
+ "<br/><div style=\"margin-top: 10px; margin-bottom: 10px; margin-left: 50px; padding-left: 15px; border-left: 3px solid #ccc; font-style: italic;\">"
+ messageText +"</div>"
+ otherRecipientNames,
false,
aslSession.getUsername(),
aslSession.getUserFullName(),

View File

@ -133,9 +133,10 @@ public interface NotificationsManager {
* @param messageUniqueIdentifier the unique identifier of the message
* @param subject the subject of the message sent
* @param messageText the text of the message (text/plain)
* @param otherRecipientsFullNames the Full Names of the other recipients. if any
* @return true if the notification is correctly delivered, false otherwise
*/
boolean notifyMessageReceived(String userIdToNotify, String messageUniqueIdentifier, String subject, String messageText);
boolean notifyMessageReceived(String userIdToNotify, String messageUniqueIdentifier, String subject, String messageText, String ... otherRecipientsFullNames);
/**
*
* @param userIdToNotify the user you want to notify

View File

@ -0,0 +1,6 @@
package org.gcube.applicationsupportlayer.social.mailing;
public enum AppType {
POST,
MSG;
}

View File

@ -35,8 +35,8 @@ public class EmailPlugin {
private static final Logger _log = LoggerFactory.getLogger(EmailPlugin.class);
protected static final int SECONDS2WAIT = 60;
public static final String WRITE_ABOVE_TO_REPLY = "- Write ABOVE THIS LINE to post a reply via email, reply with empty msg to subscribe -";
public static final String WRITE_ABOVE_MESSAGE_REPLY = "- Write ABOVE THIS LINE to reply via email";
public static final String WRITE_ABOVE_TO_REPLY = WRITE_ABOVE_MESSAGE_REPLY + ", reply with empty msg to subscribe -";
private static EmailPlugin singleton;
public static EmailPlugin getInstance() {
@ -84,6 +84,9 @@ public class EmailPlugin {
notification2Save.getType() == NotificationType.OWN_COMMENT) {
body.append("<div>").append(WRITE_ABOVE_TO_REPLY).append("</div><br />");
}
if (notification2Save.getType() == NotificationType.MESSAGE) {
body.append("<div>").append(WRITE_ABOVE_MESSAGE_REPLY).append("</div><br />");
}
body.append("<div style=\"color:#000; font-size:13px; font-family:'lucida grande',tahoma,verdana,arial,sans-serif;\">")
.append("Dear ").append(userFirstName).append(",") //dear <user>
@ -137,6 +140,9 @@ public class EmailPlugin {
notification2Save.getType() == NotificationType.OWN_COMMENT) {
body.append(WRITE_ABOVE_TO_REPLY).append("\n\n");
}
if (notification2Save.getType() == NotificationType.MESSAGE) {
body.append(WRITE_ABOVE_MESSAGE_REPLY).append("\n\n");
}
body.append("Dear ").append(userFirstName).append(",") //dear <user>
.append("\n").append(sender).append(" ").append(removedMarkup) // has done something
@ -241,7 +247,11 @@ public class EmailPlugin {
notification2Save.getType() == NotificationType.MENTION ||
notification2Save.getType() == NotificationType.OWN_COMMENT) {
String[] splits = senderEmail.split("@");
senderEmail = splits[0] + "+" + notification2Save.getSubjectid() + "@" + splits[1];
senderEmail = splits[0] + "+" + notification2Save.getSubjectid() + "$" + AppType.POST + "@" + splits[1];
}
if (notification2Save.getType() == NotificationType.MESSAGE) {
String[] splits = senderEmail.split("@");
senderEmail = splits[0] + "+" + notification2Save.getSubjectid() + "$" + AppType.MSG + "@" + splits[1];
}
// EMAIL SENDER
msg2Return.setHeader("Content-Type", "text/html; charset=UTF-8");
@ -283,7 +293,7 @@ public class EmailPlugin {
case MESSAGE:
String messageSubject = (optionalParams != null && optionalParams.length > 0) ?
optionalParams[0] : notification2Save.getSenderFullName()+" sent you a message";
return messageSubject;
return messageSubject;
case WP_FOLDER_ADDEDUSER:
return "New user in a shared folder";
case WP_FOLDER_REMOVEDUSER: