Yi EungJun 2015-04-29
NotificationMail: Fix incorrect order of messages
The order of messages of merged notification was incorrectly reversed.

This bug was caused by 96f7a52.
@ff9319d53dc4daee327161e7f4965c3a75e0dff8
app/models/NotificationMail.java
--- app/models/NotificationMail.java
+++ app/models/NotificationMail.java
@@ -274,7 +274,7 @@
                     Set<User> commentReceivers = event.findReceivers();
 
                     if (ObjectUtils.equals(stateReceivers, commentReceivers)) {
-                        stateChangedEvent.merge(event);
+                        stateChangedEvent.getMessageSources().add(0, event);
                         // No need to add the current event because it was merged.
                         continue;
                     } else {
@@ -285,6 +285,7 @@
                         // a. the notification of both of state-change and comment
                         Set<User> intersect = new HashSet<>(
                                 CollectionUtils.intersection(stateReceivers, commentReceivers));
+
                         MergedNotificationEvent mergedEvent = new MergedNotificationEvent(
                                 stateChangedEvent, Arrays.asList(event, stateChangedEvent));
                         mergedEvent.setReceivers(intersect);
app/notification/MergedNotificationEvent.java
--- app/notification/MergedNotificationEvent.java
+++ app/notification/MergedNotificationEvent.java
@@ -38,7 +38,7 @@
     public MergedNotificationEvent(@Nonnull INotificationEvent main,
                                    @Nonnull List<INotificationEvent> messageSources) {
         this.main = main;
-        this.messageSources = new ArrayList<>(messageSources);
+        this.messageSources = new LinkedList<>(messageSources);
     }
 
     public MergedNotificationEvent(@Nonnull INotificationEvent main) {
@@ -113,7 +113,7 @@
         this.receivers = receivers;
     }
 
-    public void merge(INotificationEvent event) {
-        this.messageSources.add(event);
+    public List<INotificationEvent> getMessageSources() {
+        return messageSources;
     }
 }
Add a comment
List