Hyeonjae Park 2019-01-17
Merge branch 'feature/issue-move-bugs-fix' into next
Reviewed-by: Suwon Chae
@95661bcb4a5aefb30d8e8f86af33670f4edce6bb
app/controllers/IssueApp.java
--- app/controllers/IssueApp.java
+++ app/controllers/IssueApp.java
@@ -665,9 +665,9 @@
         }
     }
 
-    private static void addIssueMovedNotification(Project previous, Issue originalIssue, Issue issue) {
+    private static void addIssueMovedNotification(Project previous, Issue originalIssue, Issue issue, Set<User> fromWatchers) {
         if (isRequestedToOtherProject(previous, originalIssue.project)) {
-            NotificationEvent notiEvent = NotificationEvent.afterIssueMoved(previous, originalIssue);
+            NotificationEvent notiEvent = NotificationEvent.afterIssueMoved(previous, originalIssue, () -> fromWatchers);
             IssueEvent.addFromNotificationEvent(notiEvent, originalIssue, UserApp.currentUser().loginId);
 
             play.Logger.debug("addIssueMovedNotification - afterIssueMoved receivers: " + notiEvent.receivers);
@@ -704,6 +704,8 @@
         issue.dueDate = JodaDateUtil.lastSecondOfDay(issue.dueDate);
 
         Issue originalIssue = Issue.findByNumber(project, number);
+        Set<User> fromWatchers = originalIssue.getWatchers();
+
         if(hasTargetProject(issue)) {
             Project toOtherProject = Project.find.byId(Long.valueOf(issue.targetProjectId));
             if (toOtherProject == null) {
@@ -744,7 +746,7 @@
                     if(isFromMyOwnPrivateProject(previous)){
                         issue.history = "";
                     } else {
-                        addIssueMovedNotification(previous, originalIssue, issue);
+                        addIssueMovedNotification(previous, originalIssue, issue, fromWatchers);
                     }
                 } else {
                     addLabels(issue, request());
app/models/NotificationEvent.java
--- app/models/NotificationEvent.java
+++ app/models/NotificationEvent.java
@@ -41,6 +41,7 @@
 import java.net.URLEncoder;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
+import java.util.function.Supplier;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -922,12 +923,12 @@
         return notiEvent;
     }
 
-    public static NotificationEvent afterIssueMoved(Project previous, Issue issue) {
+    public static NotificationEvent afterIssueMoved(Project previous, Issue issue, Supplier<Set<User>> getReceivers) {
         webhookRequest(ISSUE_MOVED, issue, previous, false);
 
         NotificationEvent notiEvent = createFromCurrentUser(issue);
         notiEvent.title = formatReplyTitle(issue);
-        notiEvent.receivers = getReceivers(issue);
+        notiEvent.receivers = getReceivers.get();
         notiEvent.eventType = ISSUE_MOVED;
         notiEvent.oldValue = previous != null ? previous.owner + "/" + previous.name : null;
         notiEvent.newValue = issue.project.owner + "/" + issue.project.name;
Add a comment
List