fix for Bug #476 Social Mail Replies: vacation notice auto reply to post is treated as "Favorite"
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/social-mail-servlet@117670 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
43206e6229
commit
9b5a6fa8f8
|
@ -54,6 +54,9 @@ import com.sun.mail.util.MailSSLSocketFactory;
|
|||
public class PeriodicTask implements Runnable {
|
||||
private static final Logger _log = LoggerFactory.getLogger(PeriodicTask.class);
|
||||
|
||||
private static final String ACCEPTED_SUBJECT_1 = "shared a news";
|
||||
private static final String ACCEPTED_SUBJECT_2 = "commented on";
|
||||
|
||||
private DatabookStore socialStore;
|
||||
private String host;
|
||||
private String mailserver_username;
|
||||
|
@ -106,6 +109,7 @@ public class PeriodicTask implements Runnable {
|
|||
|
||||
} catch (PortalException | SystemException e) {
|
||||
_log.error("Exception while trying to get the user from email address: " + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
@ -151,7 +155,8 @@ public class PeriodicTask implements Runnable {
|
|||
Message message = messages[i];
|
||||
_log.info("--------------- FOUND EMAIL ------------------");
|
||||
String subject = message.getSubject();
|
||||
_log.debug("Parsing email of " + message.getFrom()[0] + " with subject: " + subject);
|
||||
_log.info("Parsing email of " + message.getFrom()[0] + " with subject: " + subject);
|
||||
if (subject.contains(ACCEPTED_SUBJECT_1) || subject.contains(ACCEPTED_SUBJECT_2)) {
|
||||
|
||||
String feedId = extractFeedId(message);
|
||||
String commentText = extractText(portalName, feedId, message);
|
||||
|
@ -162,6 +167,7 @@ public class PeriodicTask implements Runnable {
|
|||
String emailAddress = froms == null ? null : ((InternetAddress) froms[0]).getAddress();
|
||||
|
||||
ASLSession fakeSession = getFakeASLSession(emailAddress);
|
||||
if (fakeSession != null) {
|
||||
if (escapedCommentText.trim().compareTo("") == 0) {//it is a favorite/subscription
|
||||
_log.debug("Found favorite/subscription for feed with subject: " + subject);
|
||||
favoriteFeed(feedId, fakeSession);
|
||||
|
@ -183,6 +189,13 @@ public class PeriodicTask implements Runnable {
|
|||
notifyUsersInvolved(comment, escapedCommentText, feedId, fakeSession);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_log.warn("User Not Recognized, going to discard Message from emailAddress = " + emailAddress);
|
||||
}
|
||||
}
|
||||
else {
|
||||
_log.warn("Message Subject is not one of the accepted ones, going to discard Message with subject = " + subject);
|
||||
}
|
||||
//delete this message
|
||||
message.setFlag(Flags.Flag.DELETED, true);
|
||||
_log.debug("Marked DELETE for message: " + subject);
|
||||
|
|
Loading…
Reference in New Issue