diff --git a/backend/src/main/java/io/metersphere/commons/constants/ParamConstants.java b/backend/src/main/java/io/metersphere/commons/constants/ParamConstants.java index 430b703312..c775fc7889 100644 --- a/backend/src/main/java/io/metersphere/commons/constants/ParamConstants.java +++ b/backend/src/main/java/io/metersphere/commons/constants/ParamConstants.java @@ -95,8 +95,7 @@ public interface ParamConstants { PASSWORD("smtp.password", 4), SSL("smtp.ssl", 5), TLS("smtp.tls", 6), - SMTP("smtp.smtp", 7); - /* ANON("smtp.anon", 7);*/ + ANON("smtp.anon", 7); private String key; private Integer value; diff --git a/backend/src/main/java/io/metersphere/notice/service/MailService.java b/backend/src/main/java/io/metersphere/notice/service/MailService.java index f9227bff34..aa353c816e 100644 --- a/backend/src/main/java/io/metersphere/notice/service/MailService.java +++ b/backend/src/main/java/io/metersphere/notice/service/MailService.java @@ -2,10 +2,7 @@ package io.metersphere.notice.service; import io.metersphere.base.domain.*; import io.metersphere.base.mapper.UserMapper; -import io.metersphere.commons.constants.APITestStatus; -import io.metersphere.commons.constants.NoticeConstants; -import io.metersphere.commons.constants.ParamConstants; -import io.metersphere.commons.constants.PerformanceTestStatus; +import io.metersphere.commons.constants.*; import io.metersphere.commons.user.SessionUser; import io.metersphere.commons.utils.EncryptUtils; import io.metersphere.commons.utils.LogUtil; @@ -322,6 +319,15 @@ public class MailService { context.put("start", start); context.put("end", end); context.put("id", reviewRequest.getId()); + String status = ""; + if (StringUtils.equals(TestPlanStatus.Underway.name(), reviewRequest.getStatus())) { + status = "进行中"; + } else if (StringUtils.equals(TestPlanStatus.Prepare.name(), reviewRequest.getStatus())) { + status = "未开始"; + } else if (StringUtils.equals(TestPlanStatus.Completed.name(), reviewRequest.getStatus())) { + status = "已完成"; + } + context.put("status", status); return context; } @@ -348,6 +354,15 @@ public class MailService { context.put("start", start); context.put("end", end); context.put("id", testPlan.getId()); + String status = ""; + if (StringUtils.equals(TestPlanStatus.Underway.name(), testPlan.getStatus())) { + status = "进行中"; + } else if (StringUtils.equals(TestPlanStatus.Prepare.name(), testPlan.getStatus())) { + status = "未开始"; + } else if (StringUtils.equals(TestPlanStatus.Completed.name(), testPlan.getStatus())) { + status = "已完成"; + } + context.put("status", status); User user = userMapper.selectByPrimaryKey(testPlan.getCreator()); context.put("creator", user.getName()); return context; @@ -360,6 +375,7 @@ public class MailService { List paramList = systemParameterService.getParamList(ParamConstants.Classify.MAIL.getValue()); javaMailSender.setDefaultEncoding("UTF-8"); javaMailSender.setProtocol("smtp"); + props.put("mail.smtp.auth", "true"); for (SystemParameter p : paramList) { switch (p.getParamKey()) { @@ -386,13 +402,19 @@ public class MailService { props.put("mail.smtp.starttls.enable", result); props.put("mail.smtp.starttls.required", result); break; + case "smtp.anon": + boolean isAnon = BooleanUtils.toBoolean(p.getParamValue()); + if (isAnon) { + props.put("mail.smtp.auth", "false"); + javaMailSender.setUsername(null); + javaMailSender.setPassword(null); + } + break; default: break; } } - props.put("mail.smtp.auth", "true"); - props.put("mail.smtp.timeout", "30000"); props.put("mail.smtp.connectiontimeout", "5000"); javaMailSender.setJavaMailProperties(props); @@ -407,6 +429,7 @@ public class MailService { } else { template = RegExUtils.replaceAll(template, "\\$\\{" + k + "}", "未设置"); } + } } return template; @@ -416,7 +439,7 @@ public class MailService { List addresseeIdList = new ArrayList<>(); if (StringUtils.equals(eventType, messageDetail.getEvent())) { messageDetail.getUserIds().forEach(u -> { - if (!StringUtils.equals(NoticeConstants.EXECUTOR, u) && !StringUtils.equals(NoticeConstants.EXECUTOR, u) && !StringUtils.equals(NoticeConstants.MAINTAINER, u)) { + if (!StringUtils.equals(NoticeConstants.EXECUTOR, u) && !StringUtils.equals(NoticeConstants.FOUNDER, u) && !StringUtils.equals(NoticeConstants.MAINTAINER, u)) { addresseeIdList.add(u); } if (StringUtils.equals(NoticeConstants.CREATE, eventType) && StringUtils.equals(NoticeConstants.EXECUTOR, u)) { diff --git a/backend/src/main/java/io/metersphere/service/SystemParameterService.java b/backend/src/main/java/io/metersphere/service/SystemParameterService.java index 5e459afb0b..7a9a42e66c 100644 --- a/backend/src/main/java/io/metersphere/service/SystemParameterService.java +++ b/backend/src/main/java/io/metersphere/service/SystemParameterService.java @@ -87,7 +87,14 @@ public class SystemParameterService { javaMailSender.setUsername(hashMap.get(ParamConstants.MAIL.ACCOUNT.getKey())); javaMailSender.setPassword(hashMap.get(ParamConstants.MAIL.PASSWORD.getKey())); Properties props = new Properties(); - props.put("mail.smtp.auth", "true"); + boolean isAnon = Boolean.parseBoolean(hashMap.get(ParamConstants.MAIL.ANON.getKey())); + if (isAnon) { + props.put("mail.smtp.auth", "false"); + javaMailSender.setUsername(null); + javaMailSender.setPassword(null); + } else { + props.put("mail.smtp.auth", "true"); + } if (BooleanUtils.toBoolean(hashMap.get(ParamConstants.MAIL.SSL.getKey()))) { props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); } diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java index 13d75cb5d7..a955e9c6c6 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java @@ -187,27 +187,25 @@ public class TestCaseReviewService { testCaseReviewMapper.updateByPrimaryKeySelective(testCaseReview); List userIds = new ArrayList<>(); userIds.addAll(testCaseReview.getUserIds()); - if (StringUtils.equals(TestPlanStatus.Completed.name(), testCaseReview.getStatus())) { - try { - String context = getReviewContext(testCaseReview, NoticeConstants.UPDATE); - MessageSettingDetail messageSettingDetail = noticeService.searchMessage(); - List taskList = messageSettingDetail.getReviewTask(); - taskList.forEach(r -> { - switch (r.getType()) { - case NoticeConstants.NAIL_ROBOT: - dingTaskService.sendNailRobot(r, userIds, context, NoticeConstants.UPDATE); - break; - case NoticeConstants.WECHAT_ROBOT: - wxChatTaskService.sendWechatRobot(r, userIds, context, NoticeConstants.UPDATE); - break; - case NoticeConstants.EMAIL: - mailService.sendReviewerNotice(r, userIds, testCaseReview, NoticeConstants.UPDATE); - break; - } - }); - } catch (Exception e) { - LogUtil.error(e); - } + try { + String context = getReviewContext(testCaseReview, NoticeConstants.UPDATE); + MessageSettingDetail messageSettingDetail = noticeService.searchMessage(); + List taskList = messageSettingDetail.getReviewTask(); + taskList.forEach(r -> { + switch (r.getType()) { + case NoticeConstants.NAIL_ROBOT: + dingTaskService.sendNailRobot(r, userIds, context, NoticeConstants.UPDATE); + break; + case NoticeConstants.WECHAT_ROBOT: + wxChatTaskService.sendWechatRobot(r, userIds, context, NoticeConstants.UPDATE); + break; + case NoticeConstants.EMAIL: + mailService.sendEndNotice(r, userIds, testCaseReview, NoticeConstants.UPDATE); + break; + } + }); + } catch (Exception e) { + LogUtil.error(e); } } @@ -585,7 +583,15 @@ public class TestCaseReviewService { if (StringUtils.equals(NoticeConstants.CREATE, type)) { context = "测试评审任务通知:" + user.getName() + "发起的" + "'" + reviewRequest.getName() + "'" + "待开始,计划开始时间是" + start + "计划结束时间为" + end + "请跟进"; } else if (StringUtils.equals(NoticeConstants.UPDATE, type)) { - context = "测试评审任务通知:" + user.getName() + "发起的" + "'" + reviewRequest.getName() + "'" + "已完成,计划开始时间是" + start + "计划结束时间为" + end + "已完成"; + String status = ""; + if (StringUtils.equals(TestPlanStatus.Underway.name(), reviewRequest.getStatus())) { + status = "进行中"; + } else if (StringUtils.equals(TestPlanStatus.Prepare.name(), reviewRequest.getStatus())) { + status = "未开始"; + } else if (StringUtils.equals(TestPlanStatus.Completed.name(), reviewRequest.getStatus())) { + status = "已完成"; + } + context = "测试评审任务通知:" + user.getName() + "发起的" + "'" + reviewRequest.getName() + "'" + "计划开始时间是" + start + "计划结束时间为" + end + status; } else if (StringUtils.equals(NoticeConstants.DELETE, type)) { context = "测试评审任务通知:" + user.getName() + "发起的" + "'" + reviewRequest.getName() + "'" + "计划开始时间是" + start + "计划结束时间为" + end + "已删除"; } diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java index 278e0f2da8..b4cb1346c3 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -159,13 +159,16 @@ public class TestPlanService { //进行中状态,写入实际开始时间 if (TestPlanStatus.Underway.name().equals(testPlan.getStatus())) { testPlan.setActualStartTime(System.currentTimeMillis()); - } else if (TestPlanStatus.Completed.name().equals(testPlan.getStatus())) { - List userIds = new ArrayList<>(); - userIds.add(testPlan.getPrincipal()); - AddTestPlanRequest testPlans = new AddTestPlanRequest(); //已完成,写入实际完成时间 testPlan.setActualEndTime(System.currentTimeMillis()); + + } + List userIds = new ArrayList<>(); + userIds.add(testPlan.getPrincipal()); + AddTestPlanRequest testPlans = new AddTestPlanRequest(); + int i = testPlanMapper.updateByPrimaryKeySelective(testPlan); + if (!StringUtils.isBlank(testPlan.getStatus())) { try { BeanUtils.copyBean(testPlans, getTestPlan(testPlan.getId())); String context = getTestPlanContext(testPlans, NoticeConstants.UPDATE); @@ -180,7 +183,7 @@ public class TestPlanService { wxChatTaskService.sendWechatRobot(r, userIds, context, NoticeConstants.UPDATE); break; case NoticeConstants.EMAIL: - mailService.sendTestPlanStartNotice(r, userIds, testPlans, NoticeConstants.UPDATE); + mailService.sendTestPlanEndNotice(r, userIds, testPlans, NoticeConstants.UPDATE); break; } }); @@ -188,8 +191,7 @@ public class TestPlanService { LogUtil.error(e); } } - - return testPlanMapper.updateByPrimaryKeySelective(testPlan); + return i; } private void editTestPlanProject(TestPlanDTO testPlan) { @@ -557,11 +559,19 @@ public class TestPlanService { } String context = ""; if (StringUtils.equals(NoticeConstants.CREATE, type)) { - context = "测试计划任务通知:" + user.getName() + "创建的" + "'" + testPlan.getName() + "'" + "待开始,计划开始时间是" + start + "计划结束时间为" + end + "请跟进"; + context = "测试计划任务通知:" + user.getName() + "创建的" + "'" + testPlan.getName() + "'" + "待开始,计划开始时间是:" + "'" + start + "'" + ";" + "计划结束时间是:" + "'" + end + "'" + " " + "请跟进"; } else if (StringUtils.equals(NoticeConstants.UPDATE, type)) { - context = "测试计划任务通知:" + user.getName() + "创建的" + "'" + testPlan.getName() + "'" + "已完成,计划开始时间是" + start + "计划结束时间为" + end + "已完成"; + String status = ""; + if (StringUtils.equals(TestPlanStatus.Underway.name(), testPlan.getStatus())) { + status = "进行中"; + } else if (StringUtils.equals(TestPlanStatus.Prepare.name(), testPlan.getStatus())) { + status = "未开始"; + } else if (StringUtils.equals(TestPlanStatus.Completed.name(), testPlan.getStatus())) { + status = "已完成"; + } + context = "测试计划任务通知:" + user.getName() + "创建的" + "'" + testPlan.getName() + "'" + "计划开始时间是:" + "'" + start + "'" + ";" + "计划结束时间是:" + "'" + end + "'" + " " + status; } else if (StringUtils.equals(NoticeConstants.DELETE, type)) { - context = "测试计划任务通知:" + user.getName() + "创建的" + "'" + testPlan.getName() + "'" + "计划开始时间是" + start + "计划结束时间为" + end + "已删除"; + context = "测试计划任务通知:" + user.getName() + "创建的" + "'" + testPlan.getName() + "'" + "计划开始时间是:" + "'" + start + "'" + ";" + "计划结束时间是:" + "'" + end + "'" + " " + "已删除"; } return context; } diff --git a/backend/src/main/resources/mail/ReviewComments.html b/backend/src/main/resources/mail/ReviewComments.html index c9f0514a57..feeef01250 100644 --- a/backend/src/main/resources/mail/ReviewComments.html +++ b/backend/src/main/resources/mail/ReviewComments.html @@ -6,7 +6,7 @@
-

${maintainer} 维护的
+

${maintainer}为
${testCaseName}
添加评论:${description}
点击下面链接进入用例评审页面

diff --git a/backend/src/main/resources/mail/ReviewEnd.html b/backend/src/main/resources/mail/ReviewEnd.html index a324c7f1fb..38e4751bac 100644 --- a/backend/src/main/resources/mail/ReviewEnd.html +++ b/backend/src/main/resources/mail/ReviewEnd.html @@ -7,10 +7,10 @@

${creator} 发起的:
- ${reviewName}已完成
+ ${reviewName}
计划开始时间是:${start}
计划结束时间为:${end}
- 已完成
+ ${status}
点击下面链接进入用例评审页面

${url}/#/track/review/view
diff --git a/backend/src/main/resources/mail/TestPlanEnd.html b/backend/src/main/resources/mail/TestPlanEnd.html index a4557adca9..455d69ccfb 100644 --- a/backend/src/main/resources/mail/TestPlanEnd.html +++ b/backend/src/main/resources/mail/TestPlanEnd.html @@ -7,10 +7,10 @@

${creator} 创建的:
- ${testPlanName}已完成
+ ${testPlanName}
计划开始时间是:${start}
计划结束时间为:${end}
- 已完成!
+ ${status}!
点击下面链接进入测试计划页面

${url}/#/track/plan/view
diff --git a/frontend/src/business/components/settings/system/EmailSetting.vue b/frontend/src/business/components/settings/system/EmailSetting.vue index 47d845993f..8de498081d 100644 --- a/frontend/src/business/components/settings/system/EmailSetting.vue +++ b/frontend/src/business/components/settings/system/EmailSetting.vue @@ -45,7 +45,7 @@
- +
@@ -120,7 +120,7 @@ export default { this.$set(this.formInline, "password", response.data[3].paramValue); this.$set(this.formInline, "SSL", JSON.parse(response.data[4].paramValue)); this.$set(this.formInline, "TLS", JSON.parse(response.data[5].paramValue)); - this.$set(this.formInline, "SMTP", JSON.parse(response.data[6].paramValue)); + this.$set(this.formInline, "ANON", JSON.parse(response.data[6].paramValue)); this.$nextTick(() => { this.$refs.formInline.clearValidate(); }) @@ -143,7 +143,7 @@ export default { "smtp.password": this.formInline.password, "smtp.ssl": this.formInline.SSL, "smtp.tls": this.formInline.TLS, - "smtp.smtp": this.formInline.SMTP, + "smtp.anon": this.formInline.ANON, }; this.$refs[formInline].validate((valid) => { if (valid) { @@ -173,7 +173,7 @@ export default { {paramKey: "smtp.password", paramValue: this.formInline.password, type: "password", sort: 4}, {paramKey: "smtp.ssl", paramValue: this.formInline.SSL, type: "text", sort: 5}, {paramKey: "smtp.tls", paramValue: this.formInline.TLS, type: "text", sort: 6}, - {paramKey: "smtp.smtp", paramValue: this.formInline.SMTP, type: "text", sort: 7} + {paramKey: "smtp.anon", paramValue: this.formInline.ANON, type: "text", sort: 7} ] this.$refs[formInline].validate(valid => { diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index f5994b2f9f..6974ad127a 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -1007,7 +1007,7 @@ export default { SMTP_password: 'SMTP密码', SSL: '开启SSL(如果SMTP端口是465,通常需要启用SSL)', TLS: '开启TLS(如果SMTP端口是587,通常需要启用TLS)', - SMTP: '是否匿名 SMTP', + SMTP: '是否免密 SMTP', host: '主机号不能为空', port: '端口号不能为空', account: '账户不能为空', diff --git a/frontend/src/i18n/zh-TW.js b/frontend/src/i18n/zh-TW.js index 1c6d9722a9..62a1a3e3c7 100644 --- a/frontend/src/i18n/zh-TW.js +++ b/frontend/src/i18n/zh-TW.js @@ -1008,7 +1008,7 @@ export default { SMTP_password: 'SMTP密碼', SSL: '開啟SSL(如果SMTP端口是465,通常需要啟用SSL)', TLS: '開啟TLS(如果SMTP端口是587,通常需要啟用TLS)', - SMTP: '是否匿名 SMTP', + SMTP: '是否免密 SMTP', host: '主機號不能為空', port: '端口號不能為空', account: '賬戶不能為空',