Skip to content

Commit

Permalink
Issue 3015 Show notifications in GUI - fix multiple user notifications (
Browse files Browse the repository at this point in the history
  • Loading branch information
okolesn authored Feb 22, 2023
1 parent feb9332 commit 3f50516
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@
import com.epam.pipeline.notifier.service.TemplateService;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.collections4.SetUtils;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Value;

import javax.transaction.Transactional;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

@Service
@RequiredArgsConstructor
Expand All @@ -52,11 +55,13 @@ public void notifySubscribers(final NotificationMessage message) {

private List<UserNotification> toUserNotifications(final NotificationMessage message) {
final MessageText messageText = templateService.buildMessageText(message);
final Set<Long> userIds = new HashSet<>();
if (message.getToUserId() != null) {
userIds.add(message.getToUserId());
}
userIds.addAll(ListUtils.emptyIfNull(message.getCopyUserIds()));
final List<UserNotification> results = new ArrayList<>();
final UserNotification userNotification = buildNotification(message.getToUserId(), messageText);
results.add(userNotification);
ListUtils.emptyIfNull(message.getCopyUserIds())
.forEach(userId -> results.add(buildNotification(userId, messageText)));
SetUtils.emptyIfNull(userIds).forEach(userId -> results.add(buildNotification(userId, messageText)));
return results;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ email.notification.retry.count=3
notification.scheduler.delay=30000

notification.enable.smtp=true
notification.enable.ui=false
submit.threads=2

email.smtp.server.host.name=127.0.0.1
Expand Down

0 comments on commit 3f50516

Please sign in to comment.