Skip to content
This repository has been archived by the owner on Sep 12, 2018. It is now read-only.

Commit

Permalink
NotificationMail: Fix incorrect order of messages
Browse files Browse the repository at this point in the history
The order of messages of merged notification was incorrectly reversed.

This bug was caused by 96f7a52.
  • Loading branch information
Yi EungJun committed May 12, 2015
1 parent dfcf344 commit ff9319d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion app/models/NotificationMail.java
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public EventHashKey(Resource resource, User sender) {
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 {
Expand All @@ -285,6 +285,7 @@ public EventHashKey(Resource resource, User sender) {
// 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);
Expand Down
6 changes: 3 additions & 3 deletions app/notification/MergedNotificationEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class MergedNotificationEvent implements INotificationEvent {
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) {
Expand Down Expand Up @@ -113,7 +113,7 @@ public void setReceivers(@Nonnull Set<User> receivers) {
this.receivers = receivers;
}

public void merge(INotificationEvent event) {
this.messageSources.add(event);
public List<INotificationEvent> getMessageSources() {
return messageSources;
}
}

0 comments on commit ff9319d

Please sign in to comment.