Fix 3.1.0 beta1 (#538)

* better
This commit is contained in:
RB 2022-10-18 14:24:27 +08:00 committed by GitHub
parent fc95ae37d4
commit 38cbc22084
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 46 additions and 47 deletions

View file

@ -659,7 +659,7 @@ public class AdvFilterParser extends SetUser {
String fieldName = value.substring(2, value.length() - 2);
Field field = MetadataHelper.getLastJoinField(rootEntity, fieldName);
if (field == null) {
log.warn("Invalid field : {} in {}", value, rootEntity.getName());
log.warn("Invalid var-field : {} in {}", value, rootEntity.getName());
return value;
}

View file

@ -60,7 +60,7 @@ public class SMSender {
try {
sendMail(to, subject, content);
} catch (Exception ex) {
log.error("Mail failed to send : " + to + " < " + subject, ex);
log.error("Mail failed to send : {} < {}", to, subject, ex);
}
});
}
@ -97,11 +97,18 @@ public class SMSender {
Objects.requireNonNull(mailbody.selectFirst(".rb-title")).text(subject);
Objects.requireNonNull(mailbody.selectFirst(".rb-content")).html(content);
// 处理变量
String htmlContent = mailbody.html();
// 处理公共变量
htmlContent = htmlContent.replace("%TO%", to);
htmlContent = htmlContent.replace("%TIME%", CalendarUtils.getUTCDateTimeFormat().format(CalendarUtils.now()));
htmlContent = htmlContent.replace("%APPNAME%", RebuildConfiguration.get(ConfigurationItem.AppName));
htmlContent = htmlContent.replace("%APPURL%", RebuildConfiguration.getHomeUrl());
htmlContent = htmlContent.replace("%APPLOGO%", RebuildConfiguration.getHomeUrl("commons/theme/use-logo"));
if (License.isCommercial()) {
htmlContent = htmlContent.replace("%APPNAME%", RebuildConfiguration.get(ConfigurationItem.AppName));
} else {
htmlContent = htmlContent.replace("%APPNAME%", "REBUILD");
}
String pageFooter = RebuildConfiguration.get(ConfigurationItem.PageFooter);
if (StringUtils.isNotBlank(pageFooter)) {
@ -124,7 +131,7 @@ public class SMSender {
return emailId;
} catch (EmailException ex) {
log.error("SMTP failed to send : " + to + " > " + subject, ex);
log.error("SMTP failed to send : {} > {}", to, subject, ex);
return null;
}
}
@ -150,7 +157,7 @@ public class SMSender {
String r = OkHttpUtils.post("https://api-v4.mysubmail.com/mail/send.json", params);
rJson = JSON.parseObject(r);
} catch (Exception ex) {
log.error("Submail failed to send : " + to + " > " + subject, ex);
log.error("Submail failed to send : {} > {}", to, subject, ex);
return null;
}
@ -161,7 +168,7 @@ public class SMSender {
return sendId;
} else {
log.error("Mail failed to send : " + to + " > " + subject + "\nError : " + rJson);
log.error("Mail failed to send : {} > {}\nError : {}", to, subject, rJson);
createLog(to, logContent, TYPE_EMAIL, null, rJson.getString("msg"));
return null;
}
@ -203,21 +210,13 @@ public class SMSender {
* @return
*/
protected static Element getMailTemplate() {
if (MT_CACHE != null && !Application.devMode()) return MT_CACHE.clone();
if (MT_CACHE != null) return MT_CACHE.clone();
String content = CommonsUtils.getStringOfRes("i18n/email.zh_CN.html");
Assert.notNull(content, "Cannot load template of email");
// 生硬替换
if (Application.isReady() && License.getCommercialType() > 10) {
content = content.replace("REBUILD", RebuildConfiguration.get(ConfigurationItem.AppName));
content = content.replace("https://getrebuild.com/img/logo.png", RebuildConfiguration.getHomeUrl("commons/theme/use-logo"));
content = content.replace("https://getrebuild.com/", RebuildConfiguration.getHomeUrl());
}
Document html = Jsoup.parse(content);
MT_CACHE = html.body();
MT_CACHE = html.body();
return MT_CACHE.clone();
}
@ -230,7 +229,7 @@ public class SMSender {
try {
sendSMS(to, content);
} catch (Exception ex) {
log.error("SMS failed to send : " + to, ex);
log.error("SMS failed to send : {}", to, ex);
}
});
}
@ -275,7 +274,7 @@ public class SMSender {
String r = OkHttpUtils.post("https://api-v4.mysubmail.com/sms/send.json", params);
rJson = JSON.parseObject(r);
} catch (Exception ex) {
log.error("Subsms failed to send : " + to + " > " + content, ex);
log.error("Subsms failed to send : {} > {}", to, content, ex);
return null;
} finally {
HeavyStopWatcher.clean();
@ -287,12 +286,13 @@ public class SMSender {
return sendId;
} else {
log.error("SMS failed to send : " + to + " > " + content + "\nError : " + rJson);
log.error("SMS failed to send : {} > {}\nError : {}", to, content, rJson);
createLog(to, content, TYPE_SMS, null, rJson.getString("msg"));
return null;
}
}
// @see com.rebuild.core.support.CommonsLog
private static void createLog(String to, String content, int type, String sentid, String error) {
if (!Application.isReady()) return;
@ -307,6 +307,7 @@ public class SMSender {
slog.setString("sendResult",
CommonsUtils.maxstr("ERR:" + StringUtils.defaultIfBlank(error, "Unknow"), 200));
}
Application.getCommonsService().create(slog);
}

View file

@ -1,31 +1,29 @@
<html>
<head>
<meta charset="utf-8" />
<title>MAIL TEMPLATE</title>
</head>
<head>
<meta charset="utf-8">
<title>EMAIL TEMPLATE</title>
</head>
<body>
<div style="background-color:#f5f5f5;margin:0;font-size:0.9rem;padding:20px;color:#333;font-family:Roboto,Helvetica,'Microsoft YaHei','宋体',sans-serif;line-height:1.5">
<div>
<a href="https://getrebuild.com/" target="_blank">
<img src="https://getrebuild.com/img/logo.png" alt="REBUILD" style="width:134px;display:inline-block;font-size:0"/>
<body>
<div style="background-color: #f5f5f5; margin: 0; font-size: 0.9rem; padding: 20px; color: #333; font-family: Roboto, Helvetica, 'Microsoft YaHei', '宋体', sans-serif; line-height: 1.5">
<div>
<a href="%APPURL%" target="_blank">
<img src="%APPLOGO%" alt="%APPNAME%" style="width: 134px; display: inline-block; font-size: 0" />
</a>
</div>
<div style="border:1px solid #eee;padding:30px 20px;background-color:#fff;border-radius:3px;border-top:3px solid #4285f4;max-width:720px;margin:10px 0">
<h2 class="rb-title" style="font-size:1.3rem;margin:0;font-weight:400">%TITLE%</h2>
<div class="rb-content" style="margin-top:10px">%CONTETN%</div>
</div>
<div>
<div class="rb-footer" style="margin:0;color:#888;font-size:12px;max-width:760px">
本消息由 REBUILD 系统自动发送,请不要直接回复。
<br>
<em>This email was sent to %TO% at %TIME%</em>
<br>
%PAGE_FOOTER%
</div>
<div style="border: 1px solid #eee; padding: 30px 20px; background-color: #fff; border-radius: 3px; border-top: 3px solid #4285f4; max-width: 720px; margin: 10px 0">
<h2 class="rb-title" style="font-size: 1.3rem; margin: 0; font-weight: 400">%TITLE%</h2>
<div class="rb-content" style="margin-top: 10px">%CONTETN%</div>
</div>
<div>
<div class="rb-footer" style="margin: 0; color: #888; font-size: 12px; max-width: 760px">
本消息由 %APPNAME% 系统自动发送,请不要直接回复。
<br />
<em>This email was sent to %TO% at %TIME%</em>
<br />
%PAGE_FOOTER%
</div>
</div>
</div>
</div>
</body>
</html>
</body>
</html>

View file

@ -280,7 +280,7 @@ var $regex = {
_Time: /^[0-9]{1,2}:[0-9]{1,2}(:[0-9]{1,2})?$/, // eg. 16:01:10, 10:1:9
// eslint-disable-next-line no-useless-escape
_Url: /^(http|https|ftp)\:\/\/[a-z0-9\-\.]+(:[0-9]*)?\/?([a-z0-9\-\._\?\,\'\/\\\+&amp;%\$#\=~!:])*$/i,
_Mail: /^[a-z0-9._%-]+@[a-z0-9.-]+\.[a-z]{2,4}$/i,
_Mail: /^[a-z0-9._-]+@[a-z0-9.-]+\.[a-z]{2,4}$/i,
_Number: /^[-+]?[0-9]+$/, // 数字
_Decimal: /^[-+]?\d*\.?\d+$/, // 包括小数点的数字
_Mobile: /^(1[3456789])\d{9}$/, // CN Mobile