修改钉钉消息

This commit is contained in:
昭荣伊
2019-12-13 10:00:58 +08:00
parent e045dad693
commit 89a0900ec7
@@ -51,13 +51,14 @@ public class DingDingWebHook implements IWebHook {
}
Map<String, Object> markdown = new HashMap<>();
markdown.put("title", app.getName());
String url = pathManager.getBaseURL(false) + "s/" + app.getShortCode() + "?id=" + app.getCurrentPackage().getId();
String currentPackageURL = pathManager.getBaseURL(false) + "s/" + app.getShortCode() + "?id=" + app.getCurrentPackage().getId();
String appURL = pathManager.getBaseURL(false) + "apps/" + app.getId();
String platform = "iOS";
if (app.getPlatform().equalsIgnoreCase("android")) {
platform = "Android";
}
String appInfo = String.format("[%s(%s)更新](%s)", app.getName(), platform, url);
String appInfo = String.format("[%s(%s)更新](%s)", app.getName(), platform, appURL);
String iconPath = PathManager.getFullPath(app.getCurrentPackage()) + "icon.png";
// 将图片转为 base64, 内网 ip 钉钉无法访问,直接给图片数据
@@ -65,11 +66,11 @@ public class DingDingWebHook implements IWebHook {
File codeFile = new File(codePath);
// 图片不存在,生成图片
if (!codeFile.exists()) {
QRCodeUtil.encode(url).withSize(150, 150).withIcon(new File(iconPath)).writeTo(new File(codePath));
QRCodeUtil.encode(currentPackageURL).withSize(150, 150).withIcon(new File(iconPath)).writeTo(new File(codePath));
}
String icon = "data:image/jpg;base64," + ImageUtils.convertImageToBase64(codePath);
String pathInfo = String.format("![%s](%s)", app.getName(), icon);
String otherInfo = String.format("链接:[%s](%s) \n\n 版本:%s (Build: %s)", url, url, app.getCurrentPackage().getVersion(), app.getCurrentPackage().getBuildVersion());
String otherInfo = String.format("链接:[前往下载🛫](%s) \n\n 版本:%s (Build: %s)", currentPackageURL, app.getCurrentPackage().getVersion(), app.getCurrentPackage().getBuildVersion());
String message = this.getPackageMessage(app.getCurrentPackage());
String text = appInfo + " \n\n " + pathInfo + " \n\n " + otherInfo;
if (message.length() > 0) {