|
|
|
@ -102,7 +102,7 @@ public class PeriodicTask implements Runnable {
|
|
|
|
|
SessionManager.getInstance().getASLSession(sessionID, username).setUserEmailAddress(email);
|
|
|
|
|
SessionManager.getInstance().getASLSession(sessionID, username).setUserAvatarId(thumbnailURL);
|
|
|
|
|
SessionManager.getInstance().getASLSession(sessionID, username).setUserGender(isMale? GenderType.MALE : GenderType.FEMALE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_log.debug("Created fakesession for user " + username + " email="+emailAddress);
|
|
|
|
|
|
|
|
|
|
} catch (PortalException | SystemException e) {
|
|
|
|
@ -163,26 +163,30 @@ public class PeriodicTask implements Runnable {
|
|
|
|
|
String emailAddress = froms == null ? null : ((InternetAddress) froms[0]).getAddress();
|
|
|
|
|
|
|
|
|
|
ASLSession fakeSession = getFakeASLSession(emailAddress);
|
|
|
|
|
|
|
|
|
|
Comment comment = new Comment(UUID.randomUUID().toString(), fakeSession.getUsername(),
|
|
|
|
|
new Date(), feedId, escapedCommentText, fakeSession.getUserFullName(), fakeSession.getUserAvatarId());
|
|
|
|
|
|
|
|
|
|
_log.debug("The EscapedCommentText =>" + escapedCommentText);
|
|
|
|
|
boolean commentCommitResult = false;
|
|
|
|
|
try {
|
|
|
|
|
if (socialStore.addComment(comment))
|
|
|
|
|
commentCommitResult = true;
|
|
|
|
|
} catch (FeedIDNotFoundException e) {
|
|
|
|
|
_log.error("Related post not found for this comment " + e.getMessage());
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
if (commentText.trim().compareTo("") == 0) {//it is a favorite/subscription
|
|
|
|
|
_log.debug("Found favorite/subscription for feed with subject: " + subject);
|
|
|
|
|
favoriteFeed(feedId, fakeSession);
|
|
|
|
|
}
|
|
|
|
|
if (commentCommitResult) { //the notifications should start
|
|
|
|
|
notifyUsersInvolved(comment, escapedCommentText, feedId, fakeSession);
|
|
|
|
|
else {
|
|
|
|
|
Comment comment = new Comment(UUID.randomUUID().toString(), fakeSession.getUsername(),
|
|
|
|
|
new Date(), feedId, escapedCommentText, fakeSession.getUserFullName(), fakeSession.getUserAvatarId());
|
|
|
|
|
|
|
|
|
|
_log.debug("The EscapedCommentText =>" + escapedCommentText);
|
|
|
|
|
boolean commentCommitResult = false;
|
|
|
|
|
try {
|
|
|
|
|
if (socialStore.addComment(comment))
|
|
|
|
|
commentCommitResult = true;
|
|
|
|
|
} catch (FeedIDNotFoundException e) {
|
|
|
|
|
_log.error("Related post not found for this comment " + e.getMessage());
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
if (commentCommitResult) { //the notifications should start
|
|
|
|
|
notifyUsersInvolved(comment, escapedCommentText, feedId, fakeSession);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//delete this message
|
|
|
|
|
message.setFlag(Flags.Flag.DELETED, true);
|
|
|
|
|
System.out.println("Marked DELETE for message: " + subject);
|
|
|
|
|
_log.debug("Marked DELETE for message: " + subject);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//close the socialStore and folder objects
|
|
|
|
@ -197,6 +201,40 @@ public class PeriodicTask implements Runnable {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* favorite the feed to subscribe to further comments
|
|
|
|
|
* @param feedId
|
|
|
|
|
* @param fakeSession
|
|
|
|
|
*/
|
|
|
|
|
private void favoriteFeed(String feedId, ASLSession fakeSession) {
|
|
|
|
|
Like like = new Like(UUID.randomUUID().toString(), fakeSession.getUsername(),
|
|
|
|
|
new Date(), feedId, fakeSession.getUserFullName(), fakeSession.getUserAvatarId());
|
|
|
|
|
|
|
|
|
|
boolean likeCommitResult = false;
|
|
|
|
|
try {
|
|
|
|
|
if (socialStore.like(like));
|
|
|
|
|
likeCommitResult = true;
|
|
|
|
|
} catch (FeedIDNotFoundException e) {
|
|
|
|
|
_log.error("Related post not found for this like " + e.getMessage());
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
if (likeCommitResult) { //the notification should be delivered to the post owner
|
|
|
|
|
try {
|
|
|
|
|
Feed feed = socialStore.readFeed(feedId);
|
|
|
|
|
String feedOwnerId = feed.getEntityId();
|
|
|
|
|
boolean isAppFeed = feed.isApplicationFeed();
|
|
|
|
|
|
|
|
|
|
NotificationsManager nm = new ApplicationNotificationsManager(fakeSession);
|
|
|
|
|
if (! fakeSession.getUsername().equals(feedOwnerId) && (!isAppFeed)) {
|
|
|
|
|
boolean result = nm.notifyLikedFeed(feedOwnerId, feedId, "");
|
|
|
|
|
_log.trace("Like Notification to post owner added? " + result);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* this method take care of notify all the users that need to be notified when someone comment
|
|
|
|
|
* @param comment
|
|
|
|
|