Bug #16725, Social networking: emails notification

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application-support-layer/applicationSupportLayerSocial@179509 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2019-05-22 14:02:00 +00:00
parent 2c87dc7333
commit 370b543326
5 changed files with 28 additions and 16 deletions

View File

@ -8,6 +8,7 @@
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>

View File

@ -5,4 +5,5 @@ org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.7

View File

@ -1,4 +1,8 @@
<ReleaseNotes>
<Changeset component="org.gcube.applicationsupportlayer.aslsocial.1-6-0"
date="2019-05-22">
<Change>Bug #16725, Social networking: emails notification</Change>
</Changeset>
<Changeset component="org.gcube.applicationsupportlayer.aslsocial.1-5-0"
date="2018-10-08">
<Change>Feature #12613, Replace use of "$" character with "_" when sending notification emails about posts and messages</Change>

View File

@ -10,7 +10,7 @@
<groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>aslsocial</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Social Portal ASL Extension</name>
<description>

View File

@ -54,17 +54,10 @@ public class SocialMailingUtil {
List<Comment> comments,
String commentKey,
String ... hashtags) {
String removedMarkup = notification2Save.getDescription().replaceAll("&amp;", "&");
if (hashtags != null && hashtags.length > 0) {
_log.debug("editing hyperlinks for mail client");
//notification2Save uri contains the absoulte path to the feed in the correct channel, e.g. /group/ustore_vre?oid=f1637958-34d0-48fc-b5ad-13b1116e389d
String pathToVRE = siteLandingPagePath + "?";
if (notification2Save.getUri().split("\\?").length > 0) {
pathToVRE = notification2Save.getUri().split("\\?")[0];
}
removedMarkup = removedMarkup.replace("href=\"?", "href=\""+portalURL + pathToVRE + "?"); //because there is no indication of the portal
}
removedMarkup = convertHTML2Text(removedMarkup);
removedMarkup = removedMarkup.replaceAll("(\r\n|\n)"," <br/> "); //preserve new lines
String sender = notification2Save.getSenderFullName();
String portalHost = portalURL.replaceAll("https://", "");
@ -93,7 +86,9 @@ public class SocialMailingUtil {
body.append("<div style=\"color:#000; font-size:13px; font-family:'lucida grande',tahoma,verdana,arial,sans-serif;\">")
.append("<p><a href=\"").append(userProfileLink).append("\">").append(sender).append("</a> ").append(removedMarkup) // has done something
.append("<p>")
.append(getActionLink(notification2Save, portalURL)) //Goto
.append("</p>")
.append(attachmentsNotice)
.append(SocialMailingUtil.buildHtmlDiscussion(notification2Save, feed, comments, commentKey)) // the original discussion
.append("</p>")
@ -378,6 +373,13 @@ public class SocialMailingUtil {
private static StringBuffer buildStringFromNode(Node node) {
StringBuffer buffer = new StringBuffer();
if (node instanceof Element) {
Element element = (Element) node;
if ("a".equals(element.tagName())) {
buffer.append("&nbsp;");
}
}
if (node instanceof TextNode) {
TextNode textNode = (TextNode) node;
buffer.append(textNode.text().trim());
@ -390,11 +392,13 @@ public class SocialMailingUtil {
if (node instanceof Element) {
Element element = (Element) node;
String tagName = element.tagName();
if ("a".equals(element.tagName())) {
buffer.append("&nbsp;");
}
if ("p".equals(tagName) || "br".equals(tagName)) {
buffer.append("\n");
}
}
return buffer;
}
@ -421,7 +425,7 @@ public class SocialMailingUtil {
// escape html
String feedTextNoHtml = convertHTML2Text(feed.getDescription());
feedTextNoHtml = feedTextNoHtml.replaceAll("(\r\n|\n)"," <br/> "); //preserve new lines
// build up html post + comments
if(notification2Save.getType() == NotificationType.POST_ALERT || (comments.size() == 0 && notification2Save.getType() == NotificationType.MENTION))
htmlPost += "<div style=\"margin-top: 10px; margin-bottom: 10px;padding-left: 15px; "
@ -446,9 +450,11 @@ public class SocialMailingUtil {
if(comments != null)
for (int i = 0; i < comments.size(); i++) {
String commentTextNoHtml = comments.get(i).getText().replaceAll("&amp;", "&");
commentTextNoHtml = convertHTML2Text(commentTextNoHtml);
commentTextNoHtml = commentTextNoHtml.replaceAll("(\r\n|\n)"," <br/> "); //preserve new lines
if((commentKey != null && comments.get(i).getKey().equals(commentKey)) && !(notification2Save.getType() == NotificationType.POST_ALERT)){
htmlPost += "<div style=\"margin-top: 10px; margin-bottom: 10px; margin-left: 50px; padding-left: 15px; "
+ "border-left: 3px solid #ccc; font-style: italic; font-weight:bold\">"
@ -473,7 +479,7 @@ public class SocialMailingUtil {
+ "white-space: nowrap; font-size: smaller; color: #999;\">" + formatter.format(comments.get(i).getTime()) + "</p>"
+"</div>";
}
_log.debug("***buildHtmlDiscussion returning=\n"+htmlPost);
return htmlPost;
}
}catch(Exception e){