mirror of
https://github.com/getrebuild/rebuild.git
synced 2024-11-10 08:55:31 +08:00
parent
fc95ae37d4
commit
38cbc22084
4 changed files with 46 additions and 47 deletions
|
@ -659,7 +659,7 @@ public class AdvFilterParser extends SetUser {
|
||||||
String fieldName = value.substring(2, value.length() - 2);
|
String fieldName = value.substring(2, value.length() - 2);
|
||||||
Field field = MetadataHelper.getLastJoinField(rootEntity, fieldName);
|
Field field = MetadataHelper.getLastJoinField(rootEntity, fieldName);
|
||||||
if (field == null) {
|
if (field == null) {
|
||||||
log.warn("Invalid field : {} in {}", value, rootEntity.getName());
|
log.warn("Invalid var-field : {} in {}", value, rootEntity.getName());
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class SMSender {
|
||||||
try {
|
try {
|
||||||
sendMail(to, subject, content);
|
sendMail(to, subject, content);
|
||||||
} catch (Exception ex) {
|
} 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-title")).text(subject);
|
||||||
Objects.requireNonNull(mailbody.selectFirst(".rb-content")).html(content);
|
Objects.requireNonNull(mailbody.selectFirst(".rb-content")).html(content);
|
||||||
|
|
||||||
|
// 处理变量
|
||||||
String htmlContent = mailbody.html();
|
String htmlContent = mailbody.html();
|
||||||
// 处理公共变量
|
|
||||||
htmlContent = htmlContent.replace("%TO%", to);
|
htmlContent = htmlContent.replace("%TO%", to);
|
||||||
htmlContent = htmlContent.replace("%TIME%", CalendarUtils.getUTCDateTimeFormat().format(CalendarUtils.now()));
|
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);
|
String pageFooter = RebuildConfiguration.get(ConfigurationItem.PageFooter);
|
||||||
if (StringUtils.isNotBlank(pageFooter)) {
|
if (StringUtils.isNotBlank(pageFooter)) {
|
||||||
|
@ -124,7 +131,7 @@ public class SMSender {
|
||||||
return emailId;
|
return emailId;
|
||||||
|
|
||||||
} catch (EmailException ex) {
|
} catch (EmailException ex) {
|
||||||
log.error("SMTP failed to send : " + to + " > " + subject, ex);
|
log.error("SMTP failed to send : {} > {}", to, subject, ex);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,7 +157,7 @@ public class SMSender {
|
||||||
String r = OkHttpUtils.post("https://api-v4.mysubmail.com/mail/send.json", params);
|
String r = OkHttpUtils.post("https://api-v4.mysubmail.com/mail/send.json", params);
|
||||||
rJson = JSON.parseObject(r);
|
rJson = JSON.parseObject(r);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
log.error("Submail failed to send : " + to + " > " + subject, ex);
|
log.error("Submail failed to send : {} > {}", to, subject, ex);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +168,7 @@ public class SMSender {
|
||||||
return sendId;
|
return sendId;
|
||||||
|
|
||||||
} else {
|
} 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"));
|
createLog(to, logContent, TYPE_EMAIL, null, rJson.getString("msg"));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -203,21 +210,13 @@ public class SMSender {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected static Element getMailTemplate() {
|
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");
|
String content = CommonsUtils.getStringOfRes("i18n/email.zh_CN.html");
|
||||||
Assert.notNull(content, "Cannot load template of email");
|
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);
|
Document html = Jsoup.parse(content);
|
||||||
MT_CACHE = html.body();
|
|
||||||
|
|
||||||
|
MT_CACHE = html.body();
|
||||||
return MT_CACHE.clone();
|
return MT_CACHE.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,7 +229,7 @@ public class SMSender {
|
||||||
try {
|
try {
|
||||||
sendSMS(to, content);
|
sendSMS(to, content);
|
||||||
} catch (Exception ex) {
|
} 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);
|
String r = OkHttpUtils.post("https://api-v4.mysubmail.com/sms/send.json", params);
|
||||||
rJson = JSON.parseObject(r);
|
rJson = JSON.parseObject(r);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
log.error("Subsms failed to send : " + to + " > " + content, ex);
|
log.error("Subsms failed to send : {} > {}", to, content, ex);
|
||||||
return null;
|
return null;
|
||||||
} finally {
|
} finally {
|
||||||
HeavyStopWatcher.clean();
|
HeavyStopWatcher.clean();
|
||||||
|
@ -287,12 +286,13 @@ public class SMSender {
|
||||||
return sendId;
|
return sendId;
|
||||||
|
|
||||||
} else {
|
} 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"));
|
createLog(to, content, TYPE_SMS, null, rJson.getString("msg"));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @see com.rebuild.core.support.CommonsLog
|
||||||
private static void createLog(String to, String content, int type, String sentid, String error) {
|
private static void createLog(String to, String content, int type, String sentid, String error) {
|
||||||
if (!Application.isReady()) return;
|
if (!Application.isReady()) return;
|
||||||
|
|
||||||
|
@ -307,6 +307,7 @@ public class SMSender {
|
||||||
slog.setString("sendResult",
|
slog.setString("sendResult",
|
||||||
CommonsUtils.maxstr("ERR:" + StringUtils.defaultIfBlank(error, "Unknow"), 200));
|
CommonsUtils.maxstr("ERR:" + StringUtils.defaultIfBlank(error, "Unknow"), 200));
|
||||||
}
|
}
|
||||||
|
|
||||||
Application.getCommonsService().create(slog);
|
Application.getCommonsService().create(slog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,29 @@
|
||||||
<html>
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<title>MAIL TEMPLATE</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
<head>
|
<body>
|
||||||
<meta charset="utf-8">
|
<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">
|
||||||
<title>EMAIL TEMPLATE</title>
|
<div>
|
||||||
</head>
|
<a href="%APPURL%" target="_blank">
|
||||||
|
<img src="%APPLOGO%" alt="%APPNAME%" 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="https://getrebuild.com/" target="_blank">
|
|
||||||
<img src="https://getrebuild.com/img/logo.png" alt="REBUILD" style="width:134px;display:inline-block;font-size:0"/>
|
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</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">
|
<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>
|
<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 class="rb-content" style="margin-top: 10px">%CONTETN%</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="rb-footer" style="margin:0;color:#888;font-size:12px;max-width:760px">
|
<div class="rb-footer" style="margin: 0; color: #888; font-size: 12px; max-width: 760px">
|
||||||
本消息由 REBUILD 系统自动发送,请不要直接回复。
|
本消息由 %APPNAME% 系统自动发送,请不要直接回复。
|
||||||
<br>
|
<br />
|
||||||
<em>This email was sent to %TO% at %TIME%</em>
|
<em>This email was sent to %TO% at %TIME%</em>
|
||||||
<br>
|
<br />
|
||||||
%PAGE_FOOTER%
|
%PAGE_FOOTER%
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</body>
|
||||||
</body>
|
</html>
|
||||||
|
|
||||||
</html>
|
|
||||||
|
|
|
@ -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
|
_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
|
// eslint-disable-next-line no-useless-escape
|
||||||
_Url: /^(http|https|ftp)\:\/\/[a-z0-9\-\.]+(:[0-9]*)?\/?([a-z0-9\-\._\?\,\'\/\\\+&%\$#\=~!:])*$/i,
|
_Url: /^(http|https|ftp)\:\/\/[a-z0-9\-\.]+(:[0-9]*)?\/?([a-z0-9\-\._\?\,\'\/\\\+&%\$#\=~!:])*$/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]+$/, // 数字
|
_Number: /^[-+]?[0-9]+$/, // 数字
|
||||||
_Decimal: /^[-+]?\d*\.?\d+$/, // 包括小数点的数字
|
_Decimal: /^[-+]?\d*\.?\d+$/, // 包括小数点的数字
|
||||||
_Mobile: /^(1[3456789])\d{9}$/, // CN Mobile
|
_Mobile: /^(1[3456789])\d{9}$/, // CN Mobile
|
||||||
|
|
Loading…
Reference in a new issue