From a6b39da0ba2b933e04e5efc93e0436dc72601a70 Mon Sep 17 00:00:00 2001 From: "costantino.perciante" Date: Wed, 25 Jan 2017 10:55:12 +0000 Subject: [PATCH] Fixed vre reported in the subject for some notifications (such as like notification, comment/own comment and mention notifications). The full discussion is now reconstructed only when one of the following notification types is used: like notification, comment/own comment and mention notifications git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application-support-layer/applicationSupportLayerSocial@141753 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../social/mailing/NotificationMail.java | 19 +++++++++++++------ .../social/mailing/SocialMailingUtil.java | 10 ++++++++-- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/gcube/applicationsupportlayer/social/mailing/NotificationMail.java b/src/main/java/org/gcube/applicationsupportlayer/social/mailing/NotificationMail.java index fe4bd11..9dbc64b 100644 --- a/src/main/java/org/gcube/applicationsupportlayer/social/mailing/NotificationMail.java +++ b/src/main/java/org/gcube/applicationsupportlayer/social/mailing/NotificationMail.java @@ -91,7 +91,10 @@ public class NotificationMail { String commentKey = null; String vreNameFromFeed = null; - if (notification2Send.getType() != NotificationType.MESSAGE) { + if (notification2Send.getType() == NotificationType.COMMENT || + notification2Send.getType() == NotificationType.OWN_COMMENT || + notification2Send.getType() == NotificationType.LIKE || + notification2Send.getType() == NotificationType.MENTION) { try{ String feedId = notification2Send.getSubjectid(); feed = store.readFeed(feedId); @@ -103,20 +106,24 @@ 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)) + if(notification2Send.getType().equals(NotificationType.COMMENT) || + notification2Send.getType().equals(NotificationType.OWN_COMMENT) || + notification2Send.getType().equals(NotificationType.LIKE) || + notification2Send.getType().equals(NotificationType.MENTION) + ) 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 + "]"); + + vreNameToUse + "[vreNameFromFeed is " + vreNameFromFeed + ", vreName is " + vreName + "]"); // set subject msg2Return.setSubject(SocialMailingUtil.getSubjectByNotificationType(notification2Send, vreNameToUse, user.getFirstName(), mentionedVReGroups, hashtags)); diff --git a/src/main/java/org/gcube/applicationsupportlayer/social/mailing/SocialMailingUtil.java b/src/main/java/org/gcube/applicationsupportlayer/social/mailing/SocialMailingUtil.java index d2c707d..43bc325 100644 --- a/src/main/java/org/gcube/applicationsupportlayer/social/mailing/SocialMailingUtil.java +++ b/src/main/java/org/gcube/applicationsupportlayer/social/mailing/SocialMailingUtil.java @@ -405,7 +405,10 @@ public class SocialMailingUtil { try{ - if(notification2Save.getType().equals(NotificationType.COMMENT) || notification2Save.getType().equals(NotificationType.LIKE)){ + if (notification2Save.getType() == NotificationType.COMMENT || + notification2Save.getType() == NotificationType.OWN_COMMENT || + notification2Save.getType() == NotificationType.LIKE || + notification2Save.getType() == NotificationType.MENTION){ String htmlPost = "
" + "
----

Original post:

"; // data formatter @@ -486,7 +489,10 @@ public class SocialMailingUtil { try{ - if(notification2Save.getType().equals(NotificationType.COMMENT) || notification2Save.getType().equals(NotificationType.LIKE)){ + if (notification2Save.getType() == NotificationType.COMMENT || + notification2Save.getType() == NotificationType.OWN_COMMENT || + notification2Save.getType() == NotificationType.LIKE || + notification2Save.getType() == NotificationType.MENTION){ // build discussion String discussion = "\n\n----\n\nOriginal post:";