Fixed email's subject when comments are made at root level in news feed (the vreName is extracted from the feed)

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application-support-layer/applicationSupportLayerSocial@129132 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
costantino.perciante 2016-06-16 09:08:37 +00:00
parent 1013df1f25
commit 38a879a189
2 changed files with 13 additions and 4 deletions

View File

@ -85,6 +85,7 @@ public class NotificationMail {
Feed feed = null;
List<Comment> comments = null;
String commentKey = null;
String vreNameFromFeed = null;
if (notification2Send.getType() != NotificationType.MESSAGE) {
try{
@ -98,20 +99,29 @@ public class NotificationMail {
String[] splittedVREName = feed.getVreid().split("/");
if(vreName == null)
vreName = splittedVREName[splittedVREName.length - 1];
// if the notification is a comment, extract the vre name from the feed and not from the scope
if(notification2Send.getType().equals(NotificationType.COMMENT) || notification2Send.getType().equals(NotificationType.OWN_COMMENT))
vreNameFromFeed = splittedVREName[splittedVREName.length - 1];
} catch(Exception e){
_log.error("Unable to retrieve feeds/comments", e);
}
}
String vreNameToUse = (vreNameFromFeed == null) ? vreName : vreNameFromFeed;
_log.debug("VRE Name for the email's subject is going to be "
+ vreNameToUse + "[vreNameFromFeed is " + vreNameFromFeed + ", vreName is " + vreName + "]");
// set subject
msg2Return.setSubject(SocialMailingUtil.getSubjectByNotificationType(notification2Send, vreName, user.getFirstName(), hashtags));
msg2Return.setSubject(SocialMailingUtil.getSubjectByNotificationType(notification2Send, vreNameToUse, user.getFirstName(), hashtags));
final MimeBodyPart textPart = new MimeBodyPart();
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, vreName, feed, comments, commentKey, hashtags), "text/html; charset=UTF-8");
htmlPart.setContent(SocialMailingUtil.getHTMLEmail(notification2Send, user.getFirstName(), portalURL, siteLandingPagePath, email, feed, comments, commentKey, hashtags), "text/html; charset=UTF-8");
final Multipart mp = new MimeMultipart("alternative");
mp.addBodyPart(textPart);

View File

@ -45,7 +45,6 @@ public class SocialMailingUtil {
String portalURL,
String siteLandingPagePath,
String email,
String vreName,
Feed feed,
List<Comment> comments,
String commentKey,
@ -198,7 +197,7 @@ public class SocialMailingUtil {
* @param vreName
* @return
*/
protected static String getSubjectByNotificationType(Notification notification2Save, String vreName, String userFirstName, String ...optionalParams) {
protected static String getSubjectByNotificationType(Notification notification2Save, String vreName, String userFirstName, String ...optionalParams) {
switch (notification2Save.getType()) {
case LIKE:
return notification2Save.getSenderFullName()+" favorited your post in " + (vreName == null? "" : vreName);