Hyeonjae Park 2019-01-10
issue: Fix moved issues's mail bugs
@b67ab0d775911aaceec70a154decd46cc32054ac
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);
@@ -703,7 +703,11 @@
         setMilestone(issueForm, issue);
         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 +748,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,6 +923,21 @@
         return notiEvent;
     }
 
+    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.get();
+        notiEvent.eventType = ISSUE_MOVED;
+        notiEvent.oldValue = previous != null ? previous.owner + "/" + previous.name : null;
+        notiEvent.newValue = issue.project.owner + "/" + issue.project.name;
+
+        NotificationEvent.add(notiEvent);
+
+        return notiEvent;
+    }
+
     public static NotificationEvent afterIssueMoved(Project previous, Issue issue) {
         webhookRequest(ISSUE_MOVED, issue, previous, false);
 
Add a comment
List