refactor: 收件人为空不发通知

This commit is contained in:
Captain.B 2021-08-25 11:28:32 +08:00 committed by 刘瑞斌
parent b148152d02
commit c81813f8fa
3 changed files with 10 additions and 0 deletions

View File

@ -34,6 +34,9 @@ public class DingNoticeSender extends AbstractNoticeSender {
.map(Receiver::getUserId)
.distinct()
.collect(Collectors.toList()));
if (CollectionUtils.isEmpty(phoneList)) {
return;
}
LogUtil.info("钉钉收件人地址: " + phoneList);
at.setAtMobiles(phoneList);
request.setAt(at);

View File

@ -6,6 +6,7 @@ import io.metersphere.notice.domain.Receiver;
import io.metersphere.notice.sender.AbstractNoticeSender;
import io.metersphere.notice.sender.NoticeModel;
import io.metersphere.notice.service.MailService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Component;
@ -41,6 +42,9 @@ public class MailNoticeSender extends AbstractNoticeSender {
.map(Receiver::getUserId)
.distinct()
.collect(Collectors.toList());
if (CollectionUtils.isEmpty(userIds)) {
return;
}
List<String> emails = super.getUserEmails(noticeModel, userIds);
String[] users = emails.toArray(new String[0]);
LogUtil.info("收件人地址: " + emails);

View File

@ -29,6 +29,9 @@ public class WeComNoticeSender extends AbstractNoticeSender {
.distinct()
.collect(Collectors.toList()));
message.setMentionedMobileList(phoneLists);
if (CollectionUtils.isEmpty(phoneLists)) {
return;
}
LogUtil.info("企业微信收件人: ", phoneLists);
try {
WxChatbotClient.send(messageDetail.getWebhook(), message);