
issue: Fix moved issues's mail bugs
@b67ab0d775911aaceec70a154decd46cc32054ac
--- app/controllers/IssueApp.java
+++ app/controllers/IssueApp.java
... | ... | @@ -665,9 +665,9 @@ |
665 | 665 |
} |
666 | 666 |
} |
667 | 667 |
|
668 |
- private static void addIssueMovedNotification(Project previous, Issue originalIssue, Issue issue) { |
|
668 |
+ private static void addIssueMovedNotification(Project previous, Issue originalIssue, Issue issue, Set<User> fromWatchers) { |
|
669 | 669 |
if (isRequestedToOtherProject(previous, originalIssue.project)) { |
670 |
- NotificationEvent notiEvent = NotificationEvent.afterIssueMoved(previous, originalIssue); |
|
670 |
+ NotificationEvent notiEvent = NotificationEvent.afterIssueMoved(previous, originalIssue, () -> fromWatchers); |
|
671 | 671 |
IssueEvent.addFromNotificationEvent(notiEvent, originalIssue, UserApp.currentUser().loginId); |
672 | 672 |
|
673 | 673 |
play.Logger.debug("addIssueMovedNotification - afterIssueMoved receivers: " + notiEvent.receivers); |
... | ... | @@ -703,7 +703,11 @@ |
703 | 703 |
setMilestone(issueForm, issue); |
704 | 704 |
issue.dueDate = JodaDateUtil.lastSecondOfDay(issue.dueDate); |
705 | 705 |
|
706 |
+ |
|
707 |
+ |
|
706 | 708 |
Issue originalIssue = Issue.findByNumber(project, number); |
709 |
+ Set<User> fromWatchers = originalIssue.getWatchers(); |
|
710 |
+ |
|
707 | 711 |
if(hasTargetProject(issue)) { |
708 | 712 |
Project toOtherProject = Project.find.byId(Long.valueOf(issue.targetProjectId)); |
709 | 713 |
if (toOtherProject == null) { |
... | ... | @@ -744,7 +748,7 @@ |
744 | 748 |
if(isFromMyOwnPrivateProject(previous)){ |
745 | 749 |
issue.history = ""; |
746 | 750 |
} else { |
747 |
- addIssueMovedNotification(previous, originalIssue, issue); |
|
751 |
+ addIssueMovedNotification(previous, originalIssue, issue, fromWatchers); |
|
748 | 752 |
} |
749 | 753 |
} else { |
750 | 754 |
addLabels(issue, request()); |
--- app/models/NotificationEvent.java
+++ app/models/NotificationEvent.java
... | ... | @@ -41,6 +41,7 @@ |
41 | 41 |
import java.net.URLEncoder; |
42 | 42 |
import java.util.*; |
43 | 43 |
import java.util.concurrent.TimeUnit; |
44 |
+import java.util.function.Supplier; |
|
44 | 45 |
import java.util.regex.Matcher; |
45 | 46 |
import java.util.regex.Pattern; |
46 | 47 |
|
... | ... | @@ -922,6 +923,21 @@ |
922 | 923 |
return notiEvent; |
923 | 924 |
} |
924 | 925 |
|
926 |
+ public static NotificationEvent afterIssueMoved(Project previous, Issue issue, Supplier<Set<User>> getReceivers) { |
|
927 |
+ webhookRequest(ISSUE_MOVED, issue, previous, false); |
|
928 |
+ |
|
929 |
+ NotificationEvent notiEvent = createFromCurrentUser(issue); |
|
930 |
+ notiEvent.title = formatReplyTitle(issue); |
|
931 |
+ notiEvent.receivers = getReceivers.get(); |
|
932 |
+ notiEvent.eventType = ISSUE_MOVED; |
|
933 |
+ notiEvent.oldValue = previous != null ? previous.owner + "/" + previous.name : null; |
|
934 |
+ notiEvent.newValue = issue.project.owner + "/" + issue.project.name; |
|
935 |
+ |
|
936 |
+ NotificationEvent.add(notiEvent); |
|
937 |
+ |
|
938 |
+ return notiEvent; |
|
939 |
+ } |
|
940 |
+ |
|
925 | 941 |
public static NotificationEvent afterIssueMoved(Project previous, Issue issue) { |
926 | 942 |
webhookRequest(ISSUE_MOVED, issue, previous, false); |
927 | 943 |
|
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?