From 4b0ade32467c11ec1921db197c1e82b0e04f4677 Mon Sep 17 00:00:00 2001 From: "massimiliano.assante" Date: Fri, 9 Oct 2015 08:02:47 +0000 Subject: [PATCH] Added message body in notifications for messages git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application-support-layer/applicationSupportLayerSocial@119551 82a268e6-3cf1-43bd-a215-b396298e98cf --- distro/changelog.xml | 27 ++++++++++++++----- pom.xml | 2 +- .../ApplicationNotificationsManager.java | 11 +++++--- .../social/NotificationsManager.java | 4 ++- .../social/mailing/EmailPlugin.java | 13 +++++---- 5 files changed, 39 insertions(+), 18 deletions(-) diff --git a/distro/changelog.xml b/distro/changelog.xml index 8ec8534..977fb5a 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -1,22 +1,35 @@ + + Added message body in notifications for messages + + - Added Support for user reply via mail to post and comment notifications - Added Support for user subscribe/favorite via mail to post notifications + Added Support for user reply via mail to post and comment + notifications + Added Support for user subscribe/favorite via mail to post + notifications Added Notifications support for Tabular Data Manager - Revised the way we shorten posts' text when this is very long, better heuristic used - Revised the way we format mail notification messages, user text is now more clear and visible - Revised the way we provide back links for posts, removed assumption that News Feed is always present the default community page + Revised the way we shorten posts' text when this is very long, + better heuristic used + Revised the way we format mail notification messages, user + text is now more clear and visible + Revised the way we provide back links for posts, removed + assumption that News Feed is always present the default community + page Fix for incident #1081 Notification html email formatting - problems when post is favorited + problems when post is favorited + Integrated notifications for set/unset shared folder - administrator + administrator + Integrated support for hashtags org.gcube.applicationsupportlayer aslsocial - 0.14.1-SNAPSHOT + 0.15.0-SNAPSHOT jar Social Portal ASL Extension diff --git a/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNotificationsManager.java b/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNotificationsManager.java index 1996132..048dfe7 100644 --- a/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNotificationsManager.java +++ b/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNotificationsManager.java @@ -427,21 +427,24 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen * {@inheritDoc} */ @Override - public boolean notifyMessageReceived(String userIdToNotify, String subject) { + public boolean notifyMessageReceived(String userIdToNotify, String messageId, String subject, String messageText) { + String[] optionalParams = {subject}; Notification not = new Notification( UUID.randomUUID().toString(), NotificationType.MESSAGE, userIdToNotify, //user no notify - "messageid_not_provided", //the + messageId, //the unique identifier of the message new Date(), "/group/data-e-infrastructure-gateway/messages", - "sent you a message with subject: " + escapeHtml(subject), + "sent you a message: " + + "
\"" + + escapeHtml(messageText) +"\"
", false, aslSession.getUsername(), aslSession.getUserFullName(), aslSession.getUserAvatarId()); - return saveNotification(not); + return saveNotification(not, optionalParams); } /** * {@inheritDoc} diff --git a/src/main/java/org/gcube/applicationsupportlayer/social/NotificationsManager.java b/src/main/java/org/gcube/applicationsupportlayer/social/NotificationsManager.java index f983aef..dfe45d9 100644 --- a/src/main/java/org/gcube/applicationsupportlayer/social/NotificationsManager.java +++ b/src/main/java/org/gcube/applicationsupportlayer/social/NotificationsManager.java @@ -130,10 +130,12 @@ public interface NotificationsManager { /** * * @param userIdToNotify the user you want to notify + * @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) * @return true if the notification is correctly delivered, false otherwise */ - boolean notifyMessageReceived(String userIdToNotify, String subject); + boolean notifyMessageReceived(String userIdToNotify, String messageUniqueIdentifier, String subject, String messageText); /** * * @param userIdToNotify the user you want to notify diff --git a/src/main/java/org/gcube/applicationsupportlayer/social/mailing/EmailPlugin.java b/src/main/java/org/gcube/applicationsupportlayer/social/mailing/EmailPlugin.java index d7b3bc3..d54bcdc 100644 --- a/src/main/java/org/gcube/applicationsupportlayer/social/mailing/EmailPlugin.java +++ b/src/main/java/org/gcube/applicationsupportlayer/social/mailing/EmailPlugin.java @@ -274,14 +274,16 @@ public class EmailPlugin { * @param vreName * @return */ - private static String getSubjectByNotificationType(Notification notification2Save, String portalURL, String vreName, String userFirstName, String ...hashtags) { + private static String getSubjectByNotificationType(Notification notification2Save, String portalURL, String vreName, String userFirstName, String ...optionalParams) { switch (notification2Save.getType()) { case LIKE: return notification2Save.getSenderFullName()+" favorited your post"; case COMMENT: return notification2Save.getSenderFullName()+" commented on the post"; case MESSAGE: - return notification2Save.getSenderFullName()+ " sent you a message"; + String messageSubject = (optionalParams != null && optionalParams.length > 0) ? + optionalParams[0] : notification2Save.getSenderFullName()+" sent you a message"; + return messageSubject; case WP_FOLDER_ADDEDUSER: return "New user in a shared folder"; case WP_FOLDER_REMOVEDUSER: @@ -308,9 +310,10 @@ public class EmailPlugin { return notification2Save.getSenderFullName() + " mentioned you"; case POST_ALERT: String toReturn = notification2Save.getSenderFullName() + " shared a news on " + vreName; - if (hashtags != null) - for (int i = 0; i < hashtags.length; i++) - toReturn += " " + hashtags[i]; + if (optionalParams != null) { //in this case optionalParams are the hashtags + for (int i = 0; i < optionalParams.length; i++) + toReturn += " " + optionalParams[i]; + } return toReturn; case REQUEST_CONNECTION: return "Connection request";