Allow empty CC for notification emails created using API
@@ -32,6 +32,7 @@ import java.util.stream.Collectors;
import com.epam.pipeline.entity.cluster.monitoring.ELKUsageMetric;
import com.epam.pipeline.entity.notification.NotificationTimestamp;
import org.apache.commons.collections4.ListUtils;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -409,9 +410,9 @@ public class NotificationManager { // TODO: rewrite with Strategy pattern?
message.setSubject(messageVO.getSubject());
message.setBody(messageVO.getBody());
message.setTemplateParameters(messageVO.getParameters());
- final List<Long> copyUserIds = Optional.ofNullable(messageVO.getCopyUsers())
- .orElseGet(Collections::emptyList)
+ final List<Long> copyUserIds = ListUtils.emptyIfNull(messageVO.getCopyUsers())
.stream()
+ .filter(StringUtils::isNotBlank)
.map(this::getUserByName)
.map(PipelineUser::getId)
.collect(Collectors.toList());
