Feature #11739, Revise posts and comments notification emails
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application-support-layer/applicationSupportLayerSocial@169422 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
c69f80c0f8
commit
62b473ed63
|
@ -18,7 +18,7 @@
|
|||
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<Changeset component="org.gcube.applicationsupportlayer.aslsocial.1-4-0"
|
||||
date="2018-06-19">
|
||||
<Change>Added support for storage hub model in workspace related notifications</Change>
|
||||
<Change>Feature #11739, Revise posts and comments notification emails</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.applicationsupportlayer.aslsocial.1-3-0"
|
||||
date="2017-01-16">
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -25,7 +25,7 @@
|
|||
<properties>
|
||||
<distroDirectory>distro</distroDirectory>
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.7</maven.compiler.target>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
|
|
|
@ -848,19 +848,19 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean notifyPost(String userIdToNotify, String feedid, String feedText, String ... hashtags) {
|
||||
public boolean notifyPost(String userIdToNotify, String postId, String postText, String ... hashtags) {
|
||||
StringBuilder notificationText = new StringBuilder();
|
||||
notificationText.append("posted on <b> ").append(currGroupName).append(":</b>") // has done something
|
||||
.append("<br /><br /> ").append(feedText).append(" ")
|
||||
.append("<br /><br /> ").append(postText).append(" ")
|
||||
.append("<br /><br />");
|
||||
|
||||
Notification not = new Notification(
|
||||
UUID.randomUUID().toString(),
|
||||
NotificationType.POST_ALERT,
|
||||
userIdToNotify, //user no notify
|
||||
feedid, //the post
|
||||
postId, //the post
|
||||
new Date(),
|
||||
getApplicationUrl()+"?oid="+feedid,
|
||||
getApplicationUrl()+"?oid="+postId,
|
||||
notificationText.toString(),
|
||||
false,
|
||||
currUser.getUsername(),
|
||||
|
@ -870,21 +870,21 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean notifyPost(String userIdToNotify, String feedid,
|
||||
String feedText, Set<String> mentionedVREGroups,
|
||||
public boolean notifyPost(String userIdToNotify, String postId,
|
||||
String postText, Set<String> mentionedVREGroups,
|
||||
Set<String> hashtags) {
|
||||
StringBuilder notificationText = new StringBuilder();
|
||||
notificationText.append("posted on <b> ").append(currGroupName).append(":</b>") // has done something
|
||||
.append("<br /><br /> ").append(feedText).append(" ")
|
||||
.append("<br /><br /> ").append(postText).append(" ")
|
||||
.append("<br /><br />");
|
||||
|
||||
Notification not = new Notification(
|
||||
UUID.randomUUID().toString(),
|
||||
NotificationType.POST_ALERT,
|
||||
userIdToNotify, //user no notify
|
||||
feedid, //the post
|
||||
postId, //the post
|
||||
new Date(),
|
||||
getApplicationUrl()+"?oid="+feedid,
|
||||
getApplicationUrl()+"?oid="+postId,
|
||||
notificationText.toString(),
|
||||
false,
|
||||
currUser.getUsername(),
|
||||
|
@ -897,18 +897,18 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean notifyOwnCommentReply(String userIdToNotify, String feedid, String feedText, String commentKey) {
|
||||
public boolean notifyOwnCommentReply(String userIdToNotify, String postId, String postText, String commentKey) {
|
||||
Notification not = new Notification(
|
||||
UUID.randomUUID().toString(),
|
||||
NotificationType.OWN_COMMENT,
|
||||
userIdToNotify, //user no notify
|
||||
feedid, //the post
|
||||
postId, //the post
|
||||
new Date(),
|
||||
getApplicationUrl()+"?oid="+feedid,
|
||||
getApplicationUrl()+"?oid="+postId,
|
||||
"commented on your post: "
|
||||
+ "<div style=\"margin-top: 10px; margin-bottom: 10px; margin-left: 50px; padding-left: 15px; "
|
||||
+ "border-left: 3px solid #ccc; font-style: italic;\">\""
|
||||
+ feedText +"\"</div>",
|
||||
+ postText +"\"</div>",
|
||||
false,
|
||||
currUser.getUsername(),
|
||||
currUser.getFullname(),
|
||||
|
@ -920,7 +920,7 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean notifyCommentReply(String userIdToNotify, String feedid, String commentText, String feedOwnerFullName, String feedOwnerId, String commentKey) {
|
||||
public boolean notifyCommentReply(String userIdToNotify, String postId, String commentText, String feedOwnerFullName, String feedOwnerId, String commentKey) {
|
||||
String notificationText = (currUser.getUsername().compareTo(feedOwnerId) == 0) ?
|
||||
"also commented on his post: "
|
||||
+ "<div style=\"margin-top: 10px; margin-bottom: 10px; margin-left: 50px; padding-left: 15px; border-left: 3px solid #ccc; font-style: italic;\">\""
|
||||
|
@ -933,9 +933,9 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
|||
UUID.randomUUID().toString(),
|
||||
NotificationType.COMMENT,
|
||||
userIdToNotify, //user no notify
|
||||
feedid, //the post
|
||||
postId, //the post
|
||||
new Date(),
|
||||
getApplicationUrl()+"?oid="+feedid,
|
||||
getApplicationUrl()+"?oid="+postId,
|
||||
notificationText,
|
||||
false,
|
||||
currUser.getUsername(),
|
||||
|
@ -948,21 +948,21 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean notifyCommentOnFavorite(String userIdToNotify, String feedid, String commentText, String commentKey) {
|
||||
return notifyCommentOnLike(userIdToNotify, feedid, commentText, commentKey);
|
||||
public boolean notifyCommentOnFavorite(String userIdToNotify, String postId, String commentText, String commentKey) {
|
||||
return notifyCommentOnLike(userIdToNotify, postId, commentText, commentKey);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean notifyCommentOnLike(String userIdToNotify, String feedid, String commentText, String commentKey) {
|
||||
public boolean notifyCommentOnLike(String userIdToNotify, String postId, String commentText, String commentKey) {
|
||||
Notification not = new Notification(
|
||||
UUID.randomUUID().toString(),
|
||||
NotificationType.COMMENT,
|
||||
userIdToNotify, //user no notify
|
||||
feedid, //the post
|
||||
postId, //the post
|
||||
new Date(),
|
||||
getApplicationUrl()+"?oid="+feedid,
|
||||
getApplicationUrl()+"?oid="+postId,
|
||||
"commented on one of your liked posts: "
|
||||
+ "<div style=\"margin-top: 10px; margin-bottom: 10px; margin-left: 50px; padding-left: 15px; border-left: 3px solid #ccc; font-style: italic;\">\""
|
||||
+ commentText +"\"</div>",
|
||||
|
@ -977,16 +977,16 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean notifyUserTag(String userIdToNotify, String feedid, String feedText, String commentKey) {
|
||||
public boolean notifyUserTag(String userIdToNotify, String postId, String postText, String commentKey) {
|
||||
Notification not = new Notification(
|
||||
UUID.randomUUID().toString(),
|
||||
NotificationType.MENTION,
|
||||
userIdToNotify, //user no notify
|
||||
feedid, //the post
|
||||
postId, //the post
|
||||
new Date(),
|
||||
getApplicationUrl()+"?oid="+feedid,
|
||||
getApplicationUrl()+"?oid="+postId,
|
||||
"mentioned you: " + "<div style=\"margin-top: 10px; margin-bottom: 10px; margin-left: 50px; padding-left: 15px; border-left: 3px solid #ccc; font-style: italic;\">\""
|
||||
+ feedText +"\"</div>",
|
||||
+ postText +"\"</div>",
|
||||
false,
|
||||
currUser.getUsername(),
|
||||
currUser.getFullname(),
|
||||
|
@ -998,15 +998,23 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean notifyLikedFeed(String userIdToNotify, String feedid, String feedText) {
|
||||
@Deprecated
|
||||
public boolean notifyLikedFeed(String userIdToNotify, String postId, String postText) {
|
||||
return notifyLikedPost(userIdToNotify, postId, postText);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean notifyLikedPost(String userIdToNotify, String postId, String postText) {
|
||||
|
||||
Notification not = new Notification(
|
||||
UUID.randomUUID().toString(),
|
||||
NotificationType.LIKE,
|
||||
userIdToNotify, //user no notify
|
||||
feedid, //the post
|
||||
postId, //the post
|
||||
new Date(),
|
||||
getApplicationUrl()+"?oid="+feedid,
|
||||
getApplicationUrl()+"?oid="+postId,
|
||||
"liked/subscribed to one of your post",
|
||||
false,
|
||||
currUser.getUsername(),
|
||||
|
|
|
@ -278,85 +278,97 @@ public interface NotificationsManager {
|
|||
* use to notify a user that someone created this post
|
||||
*
|
||||
* @param userIdToNotify the user you want to notify
|
||||
* @param feedid the liked feedid
|
||||
* @param feedText the liked feed text or a portion of it
|
||||
* @param postid the liked postid
|
||||
* @param postText the liked post text or a portion of it
|
||||
* @return true if the notification is correctly delivered, false otherwise
|
||||
*/
|
||||
@Deprecated
|
||||
boolean notifyPost(String userIdToNotify, String feedid, String feedText, String ... hashtags);
|
||||
boolean notifyPost(String userIdToNotify, String postid, String postText, String ... hashtags);
|
||||
|
||||
/**
|
||||
* use to notify a user that someone created this post
|
||||
*
|
||||
* @param userIdToNotify the user you want to notify
|
||||
* @param feedid the liked feedid
|
||||
* @param feedText the liked feed text or a portion of it
|
||||
* @param postid the liked postid
|
||||
* @param postText the liked post text or a portion of it
|
||||
* @param mentionedVREGroups the names of the mentioned vre's groups, if any
|
||||
* @param hashtags the set of hashtags in the post, if any
|
||||
* @return true if the notification is correctly delivered, false otherwise
|
||||
*/
|
||||
boolean notifyPost(String userIdToNotify, String feedid, String feedText, Set<String> mentionedVREGroups, Set<String> hashtags);
|
||||
boolean notifyPost(String userIdToNotify, String postid, String postText, Set<String> mentionedVREGroups, Set<String> hashtags);
|
||||
|
||||
/**
|
||||
* use to notify a user that someone commented on his post
|
||||
*
|
||||
* @param userIdToNotify the user you want to notify
|
||||
* @param feedid the liked feedid
|
||||
* @param feedText the liked feed text or a portion of it
|
||||
* @param postid the liked postid
|
||||
* @param postText the liked post text or a portion of it
|
||||
* @param commentKey when sending email, stop the shown discussion at that comment
|
||||
* @return true if the notification is correctly delivered, false otherwise
|
||||
*/
|
||||
boolean notifyOwnCommentReply(String userIdToNotify, String feedid, String feedText, String commentKey);
|
||||
boolean notifyOwnCommentReply(String userIdToNotify, String postid, String postText, String commentKey);
|
||||
/**
|
||||
* use to notify a user that commented on a post (Not his) that someone commented too
|
||||
*
|
||||
* @param userIdToNotify the user you want to notify
|
||||
* @param feedid the liked feedid
|
||||
* @param feedText the liked feed text or a portion of it
|
||||
* @param feedOwnerFullName the full name of the user who created this post
|
||||
* @param postid the liked postid
|
||||
* @param postText the liked post text or a portion of it
|
||||
* @param postOwnerFullName the full name of the user who created the post
|
||||
* @param postOwnerId the username of the user who created the post
|
||||
* @param commentKey when sending email, stop the shown discussion at that comment
|
||||
* @return true if the notification is correctly delivered, false otherwise
|
||||
*/
|
||||
boolean notifyCommentReply(String userIdToNotify, String feedid, String feedText, String feedOwnerFullName, String feedOwnerId, String commentKey);
|
||||
boolean notifyCommentReply(String userIdToNotify, String postid, String postText, String postOwnerFullName, String postOwnerId, String commentKey);
|
||||
/**
|
||||
* @deprecated use notifyCommentOnLike
|
||||
* use to notify a user that someone commented on one of his liked posts
|
||||
*
|
||||
* @param userIdToNotify the user you want to notify
|
||||
* @param feedid the liked feedid
|
||||
* @param postid the liked postid
|
||||
* @param commentText the commentText
|
||||
* @param commentKey when sending email, stop the shown discussion at that comment
|
||||
* @return true if the notification is correctly delivered, false otherwise
|
||||
*/
|
||||
boolean notifyCommentOnFavorite(String userIdToNotify, String feedid, String commentText, String commentKey);
|
||||
boolean notifyCommentOnFavorite(String userIdToNotify, String postid, String commentText, String commentKey);
|
||||
/**
|
||||
*
|
||||
* @param userIdToNotify the user you want to notify
|
||||
* @param feedid the liked feedid
|
||||
* @param postid the liked postid
|
||||
* @param commentText the commentText
|
||||
* @param commentKey when sending email, stop the shown discussion at that comment
|
||||
* @return true if the notification is correctly delivered, false otherwise
|
||||
*/
|
||||
boolean notifyCommentOnLike(String userIdToNotify, String feedid, String commentText, String commentKey);
|
||||
boolean notifyCommentOnLike(String userIdToNotify, String postid, String commentText, String commentKey);
|
||||
/**
|
||||
* use to notify a user that he was mentioned (tagged) on a post
|
||||
*
|
||||
* @param userIdToNotify the user you want to notify
|
||||
* @param feedid the liked feedid
|
||||
* @param postid the liked postid
|
||||
* @param feedText the liked feed text or a portion of it
|
||||
* @param commentKey when sending email, stop the shown discussion at that comment
|
||||
* @return true if the notification is correctly delivered, false otherwise
|
||||
*/
|
||||
boolean notifyUserTag(String userIdToNotify, String feedid, String commentText, String commentKey);
|
||||
boolean notifyUserTag(String userIdToNotify, String postid, String commentText, String commentKey);
|
||||
/**
|
||||
* use to notify a user he got one of his post liked
|
||||
*
|
||||
* @param userIdToNotify the user you want to notify
|
||||
* @param feedid the liked feedid
|
||||
* @param feedText the liked feed text or a portion of it
|
||||
* @param postid the liked postid
|
||||
* @param postText the liked post text or a portion of it
|
||||
* @return true if the notification is correctly delivered, false otherwise
|
||||
* @deprecated use notifyLikedPost
|
||||
*/
|
||||
@Deprecated
|
||||
boolean notifyLikedFeed(String userIdToNotify, String postid, String postText);
|
||||
/**
|
||||
* use to notify a user he got one of his post liked
|
||||
*
|
||||
* @param userIdToNotify the user you want to notify
|
||||
* @param postid the liked postid
|
||||
* @param postText the liked post text or a portion of it
|
||||
* @return true if the notification is correctly delivered, false otherwise
|
||||
*/
|
||||
boolean notifyLikedFeed(String userIdToNotify, String feedid, String feedText);
|
||||
boolean notifyLikedPost(String userIdToNotify, String postid, String postText);
|
||||
/**
|
||||
* use to notify a user he got one of his job finished
|
||||
*
|
||||
|
|
|
@ -82,7 +82,8 @@ public class NotificationMail {
|
|||
}
|
||||
// EMAIL SENDER
|
||||
msg2Return.setHeader("Content-Type", "text/html; charset=UTF-8");
|
||||
msg2Return.setFrom(new InternetAddress(senderEmail, portalName));
|
||||
String senderEmailText = new StringBuilder(notification2Send.getSenderFullName()).append(" on ").append(portalName).toString();
|
||||
msg2Return.setFrom(new InternetAddress(senderEmail, senderEmailText));
|
||||
msg2Return.addRecipient(Message.RecipientType.TO, new InternetAddress(email));
|
||||
|
||||
// retrieve post/comments from its id (if possible)
|
||||
|
@ -132,7 +133,7 @@ public class NotificationMail {
|
|||
textPart.setContent(SocialMailingUtil.getTextEmail(notification2Send, user.getFirstName(), portalURL, siteLandingPagePath, email, feed, comments, commentKey, hashtags), "text/plain; charset=UTF-8");
|
||||
|
||||
final MimeBodyPart htmlPart = new MimeBodyPart();
|
||||
htmlPart.setContent(SocialMailingUtil.getHTMLEmail(notification2Send, user.getFirstName(), portalURL, siteLandingPagePath, email, feed, comments, commentKey, hashtags), "text/html; charset=UTF-8");
|
||||
htmlPart.setContent(SocialMailingUtil.getHTMLEmail(vreNameToUse, notification2Send, user.getFirstName(), portalURL, siteLandingPagePath, email, feed, comments, commentKey, hashtags), "text/html; charset=UTF-8");
|
||||
|
||||
final Multipart mp = new MimeMultipart("alternative");
|
||||
mp.addBodyPart(textPart);
|
||||
|
|
|
@ -3,11 +3,13 @@ package org.gcube.applicationsupportlayer.social.mailing;
|
|||
import java.text.Format;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager;
|
||||
import org.gcube.common.portal.GCubePortalConstants;
|
||||
import org.gcube.portal.databook.shared.Comment;
|
||||
import org.gcube.portal.databook.shared.Feed;
|
||||
import org.gcube.portal.databook.shared.Notification;
|
||||
|
@ -43,7 +45,7 @@ public class SocialMailingUtil {
|
|||
* @param hashtags
|
||||
* @return
|
||||
*/
|
||||
protected static String getHTMLEmail(Notification notification2Save,
|
||||
protected static String getHTMLEmail(String vreName, Notification notification2Save,
|
||||
String userFirstName,
|
||||
String portalURL,
|
||||
String siteLandingPagePath,
|
||||
|
@ -85,10 +87,12 @@ public class SocialMailingUtil {
|
|||
body.append("<div>").append(WRITE_ABOVE_MESSAGE_REPLY).append("</div><br />");
|
||||
attachmentsNotice = "<br/><p>Please note that email replies do not support attachments.</p>";
|
||||
}
|
||||
|
||||
String userProfileLink = new StringBuffer(getVREUrl(portalURL, vreName))
|
||||
.append("/").append(getUserProfileLink(notification2Save.getSenderid())).toString();
|
||||
|
||||
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>
|
||||
.append("<p>").append(sender).append(" ").append(removedMarkup) // has done something
|
||||
.append("<p><a href=\"").append(userProfileLink).append("\">").append(sender).append("</a> ").append(removedMarkup) // has done something
|
||||
.append(getActionLink(notification2Save, portalURL)) //Goto
|
||||
.append(attachmentsNotice)
|
||||
.append(SocialMailingUtil.buildHtmlDiscussion(notification2Save, feed, comments, commentKey)) // the original discussion
|
||||
|
@ -113,6 +117,7 @@ public class SocialMailingUtil {
|
|||
|
||||
return body.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param notification2Save
|
||||
|
@ -538,4 +543,27 @@ public class SocialMailingUtil {
|
|||
|
||||
return "";
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param gatewayURL
|
||||
* @param vreName the VRE Name (e.g. AquaMaps)
|
||||
* @return
|
||||
*/
|
||||
private static String getVREUrl(String gatewayURL, String vreName) {
|
||||
return new StringBuffer(gatewayURL)
|
||||
.append(GCubePortalConstants.PREFIX_GROUP_URL)
|
||||
.append("/").append(vreName.toLowerCase()).toString();
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
private static String getUserProfileLink(String username) {
|
||||
return "profile?"+ new String(
|
||||
Base64.getEncoder().encodeToString(GCubePortalConstants.USER_PROFILE_OID.getBytes())+
|
||||
"="+
|
||||
new String( Base64.getEncoder().encodeToString(username.getBytes()) )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue