diff --git a/backend/src/main/java/io/metersphere/notice/sender/impl/DingNoticeSender.java b/backend/src/main/java/io/metersphere/notice/sender/impl/DingNoticeSender.java index fe1327af69..ea4a6e6c51 100644 --- a/backend/src/main/java/io/metersphere/notice/sender/impl/DingNoticeSender.java +++ b/backend/src/main/java/io/metersphere/notice/sender/impl/DingNoticeSender.java @@ -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); diff --git a/backend/src/main/java/io/metersphere/notice/sender/impl/MailNoticeSender.java b/backend/src/main/java/io/metersphere/notice/sender/impl/MailNoticeSender.java index 791216f32e..b534b430a5 100644 --- a/backend/src/main/java/io/metersphere/notice/sender/impl/MailNoticeSender.java +++ b/backend/src/main/java/io/metersphere/notice/sender/impl/MailNoticeSender.java @@ -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 emails = super.getUserEmails(noticeModel, userIds); String[] users = emails.toArray(new String[0]); LogUtil.info("收件人地址: " + emails); diff --git a/backend/src/main/java/io/metersphere/notice/sender/impl/WeComNoticeSender.java b/backend/src/main/java/io/metersphere/notice/sender/impl/WeComNoticeSender.java index 3e56cb294d..6e52ccd323 100644 --- a/backend/src/main/java/io/metersphere/notice/sender/impl/WeComNoticeSender.java +++ b/backend/src/main/java/io/metersphere/notice/sender/impl/WeComNoticeSender.java @@ -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);