From e9b94a5eff9b1c7c9539acd6b7dc3c7b06667799 Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Thu, 16 Jun 2022 15:55:51 +0200 Subject: [PATCH] ported to git --- pom.xml | 2 +- .../thread/CommentNotificationsThread.java | 43 ++++++++++++------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/pom.xml b/pom.xml index b676543..3dbb303 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ org.gcube.distribution maven-portal-bom - 3.6.3 + 3.6.4 pom import diff --git a/src/main/java/org/gcube/portal/notifications/thread/CommentNotificationsThread.java b/src/main/java/org/gcube/portal/notifications/thread/CommentNotificationsThread.java index 9acff86..637c78f 100644 --- a/src/main/java/org/gcube/portal/notifications/thread/CommentNotificationsThread.java +++ b/src/main/java/org/gcube/portal/notifications/thread/CommentNotificationsThread.java @@ -24,30 +24,41 @@ public class CommentNotificationsThread implements Runnable { String commenterUserId; String commentedFeedId; private String commentText; - private String feedOwnerId; + private String postOwnerId; private NotificationsManager nm; private String commentKey; private HashSet userIdsToNotify; //needed to avoid sending notification twice (the user who favorited gets the notification anyways) - private ArrayList favorites; + private ArrayList likes; private UserManager userManager; - + /** + * + * @param storeInstance + * @param userManager + * @param commenterUserId + * @param commentedPostId + * @param commentText + * @param nm + * @param postOwnerId + * @param commentKey + * @param likes + */ public CommentNotificationsThread(DatabookStore storeInstance, UserManager userManager, String commenterUserId, - String commentedFeedId, String commentText, NotificationsManager nm, String feedOwnerId, String commentKey, ArrayList favorites) { + String commentedPostId, String commentText, NotificationsManager nm, String postOwnerId, String commentKey, ArrayList likes) { super(); this.nm = nm; this.commenterUserId = commenterUserId; - this.commentedFeedId = commentedFeedId; + this.commentedFeedId = commentedPostId; this.commentText = commentText; - this.feedOwnerId = feedOwnerId; + this.postOwnerId = postOwnerId; this.commentKey = commentKey; - this.favorites = favorites; + this.likes = likes; this.userManager = userManager; userIdsToNotify = new HashSet(); - List feedComments = storeInstance.getAllCommentByFeed(commentedFeedId); - for (Comment comment : feedComments) { + List postComments = storeInstance.getAllCommentByFeed(commentedPostId); + for (Comment comment : postComments) { if (comment.getUserid().compareTo(commenterUserId) != 0) { userIdsToNotify.add(comment.getUserid()); } @@ -59,23 +70,23 @@ public class CommentNotificationsThread implements Runnable { @Override public void run() { - String feedOwnerFullName = ""; + String postOwnerFullName = ""; try { - feedOwnerFullName = userManager.getUserByUsername(feedOwnerId).getFullname(); + postOwnerFullName = userManager.getUserByUsername(postOwnerId).getFullname(); } catch (Exception e) { - feedOwnerFullName = feedOwnerId; + postOwnerFullName = postOwnerId; } //get the list of userid who liked the post ArrayList favoriteUserIds = new ArrayList<>(); - for (Like favorite : favorites) { + for (Like favorite : likes) { favoriteUserIds.add(favorite.getUserid()); } if (userIdsToNotify != null) { for (String userId : userIdsToNotify) { - if (userId.compareTo(feedOwnerId) != 0 && !(favoriteUserIds.contains(userId)) ) { //avoid notifying the owner and the user who liked twice - boolean result = nm.notifyCommentReply(userId, commentedFeedId, commentText, feedOwnerFullName, feedOwnerId, commentKey); - _log.trace("Sending Notification for also commented to: " + feedOwnerFullName + " result?"+ result); + if (userId.compareTo(postOwnerId) != 0 && !(favoriteUserIds.contains(userId)) ) { //avoid notifying the owner and the user who liked twice + boolean result = nm.notifyCommentReply(userId, commentedFeedId, commentText, postOwnerFullName, postOwnerId, commentKey); + _log.trace("Sending Notification for also commented to: " + postOwnerFullName + " result?"+ result); } } }