From bd160b53967cf580b404d65a1ecef181be581976 Mon Sep 17 00:00:00 2001 From: "massimiliano.assante" Date: Tue, 4 Mar 2014 23:40:14 +0000 Subject: [PATCH] added support to alert the users of a VRE when posting in to a VRE. Added new notification mothod to support this git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application-support-layer/applicationSupportLayerSocial@92661 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../ApplicationNotificationsManager.java | 27 ++++++++++++++++++- .../social/NotificationsManager.java | 9 +++++++ .../social/mailing/EmailPlugin.java | 10 ++++--- 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNotificationsManager.java b/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNotificationsManager.java index 2937d72..8975d33 100644 --- a/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNotificationsManager.java +++ b/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNotificationsManager.java @@ -395,6 +395,31 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen * {@inheritDoc} */ @Override + public boolean notifyPost(String userIdToNotify, String feedid, String feedText) { + + StringBuilder notificationText = new StringBuilder(); + notificationText.append("posted a news on ").append(aslSession.getGroupName()).append(":") // has done something + .append("

").append(escapeHtml(feedText)).append(". ") + .append("

Follow the discussion and comment it. "); + + Notification not = new Notification( + UUID.randomUUID().toString(), + NotificationType.POST_ALERT, + userIdToNotify, //user no notify + feedid, //the post + new Date(), + getApplicationUrl()+"?oid="+feedid, + notificationText.toString(), + false, + aslSession.getUsername(), + aslSession.getUserFullName(), + aslSession.getUserAvatarId()); + return saveNotification(not); + } + /** + * {@inheritDoc} + */ + @Override public boolean notifyOwnCommentReply(String userIdToNotify, String feedid, String feedText) { Notification not = new Notification( UUID.randomUUID().toString(), @@ -727,5 +752,5 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen aslSession.getUserAvatarId()); return saveNotification(not); - } + } } diff --git a/src/main/java/org/gcube/applicationsupportlayer/social/NotificationsManager.java b/src/main/java/org/gcube/applicationsupportlayer/social/NotificationsManager.java index b4863db..0b8cf80 100644 --- a/src/main/java/org/gcube/applicationsupportlayer/social/NotificationsManager.java +++ b/src/main/java/org/gcube/applicationsupportlayer/social/NotificationsManager.java @@ -136,6 +136,15 @@ public interface NotificationsManager { * @return true if the notification is correctly delivered, false otherwise */ boolean notifyDeletedCalendarEvent(String userIdToNotify, String eventTitle, String eventType, Date startDate, Date endingDate); + /** + * 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 + * @return true if the notification is correctly delivered, false otherwise + */ + boolean notifyPost(String userIdToNotify, String feedid, String feedText); /** * use to notify a user that someone commented on his post * 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 76fff0d..0d134d1 100644 --- a/src/main/java/org/gcube/applicationsupportlayer/social/mailing/EmailPlugin.java +++ b/src/main/java/org/gcube/applicationsupportlayer/social/mailing/EmailPlugin.java @@ -99,14 +99,13 @@ public class EmailPlugin { try { // EMAIL SENDER Address from = new InternetAddress("no-reply@d4science.org"); + mimeMessage.setHeader("Content-Type", "text/html; charset=UTF-8"); mimeMessage.setFrom(from); - Address address = new InternetAddress(email); mimeMessage.addRecipient(Message.RecipientType.TO, address); mimeMessage.setSubject(getSubjectByNotificationType(notification2Save, portalUrl, vreName)); - // mimeMessage.setText(body); - mimeMessage.setContent(getHTMLEmail(notification2Save, user.getFirstName(), portalUrl, email), "text/html"); + mimeMessage.setContent(getHTMLEmail(notification2Save, user.getFirstName(), portalUrl, email), "text/html; charset=UTF-8"); mimeMessage.setSentDate(new Date()); Transport.send(mimeMessage); _log.trace("notification email sent successfully"); @@ -143,6 +142,8 @@ public class EmailPlugin { return portalHost + ": Reply on your post notification"; case MENTION: return portalHost + ": Mention in a post notification"; + case POST_ALERT: + return portalHost + ": Important post shared notification"; case REQUEST_CONNECTION: return portalHost + ": Connection request notification"; case JOB_COMPLETED_NOK: @@ -219,6 +220,9 @@ public class EmailPlugin { case OWN_COMMENT: actionLink.append("\">.").append(" See the Post").append(""); break; + case POST_ALERT: + actionLink.append("\">").append("See this News").append(""); + break; case REQUEST_CONNECTION: actionLink.append("\">.").append(" Go to Contacts Center").append(""); break;