Commit cf2db300 authored by zhu-mingye's avatar zhu-mingye

fixbug alert instance

parent 3f8ff44b
......@@ -8,7 +8,7 @@ package com.dlink.alert.feishu;
public final class FeiShuConstants {
static final String TYPE = "FeiShu";
static final String MARKDOWN_QUOTE = "> ";
static final String MARKDOWN_ENTER = "\n";
static final String MARKDOWN_ENTER = "/n";
static final String WEB_HOOK = "webhook";
static final String KEY_WORD = "keyword";
static final String SECRET = "secret";
......@@ -21,7 +21,7 @@ public final class FeiShuConstants {
static final String AT_ALL = "isAtAll";
static final String AT_USERS = "users";
static final String FEI_SHU_TEXT_TEMPLATE = "{\"msg_type\":\"{msg_type}\",\"content\":{\"{msg_type}\":\"{msg} {users} \" }}";
static final String FEI_SHU_POST_TEMPLATE ="{\"msg_type\":\"{msg_type}\",\"content\":{\"{msg_type}\":{\"zh_cn\":{\"title\":\"{keyword}\",\"content\":[[{\"tag\":\"text\",\"text\":\"{msg}\"},{users}]]}}}}";
static final String FEI_SHU_POST_TEMPLATE ="{\"msg_type\":\"{msg_type}\",\"content\":{\"{msg_type}\":{\"zh_cn\":{\"title\":\"{keyword}\",\"content\":[[{\"tag\":\"text\",\"un_escape\": true,\"text\":\"{msg}\"},{users}]]}}}}";
private FeiShuConstants() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
......
......@@ -138,14 +138,13 @@ public final class FeiShuSender {
}
StringBuilder contents = new StringBuilder(100);
contents.append(String.format("`%s`/n ", alertMsg.getName()));
contents.append(String.format("`%s`"+FeiShuConstants.MARKDOWN_ENTER, alertMsg.getName()));
for (Map map : list) {
for (Entry<String, Object> entry : (Iterable<Entry<String, Object>>) map.entrySet()) {
String key = entry.getKey();
String value = entry.getValue().toString();
contents.append(FeiShuConstants.MARKDOWN_QUOTE);
contents.append(key + ":" + value);
contents.append(" /n ");
contents.append(key + ":" + value).append(FeiShuConstants.MARKDOWN_ENTER);
}
}
return contents.toString();
......
......@@ -43,7 +43,7 @@ public class WeChatSender {
private final String weChatTokenUrlReplace;
private final String weChatToken;
private final String sendType;
private final String showType;
private static String showType;
private final String webhookUrl;
private final String KeyWord ;
private final Boolean atAll;
......@@ -76,7 +76,7 @@ public class WeChatSender {
userList = Arrays.asList(weChatUsers.split(","));
}
if(atAll){
userList.add("ALL");
userList.add("所有人");
}
String data ="";
......@@ -171,10 +171,14 @@ public class WeChatSender {
*/
private static String mkMarkDownAtUsers(List<String> userList){
StringBuilder builder = new StringBuilder();
StringBuilder builder = new StringBuilder("\n");
if (Asserts.isNotNull(userList)) {
userList.forEach(value -> {
if (value.equals("所有人") && showType.equals(ShowType.TEXT.getValue())) {
builder.append("@所有人 ");
}else{
builder.append("<@").append(value).append("> ");
}
});
}
return builder.toString();
......
......@@ -136,8 +136,6 @@ const WeChatForm: React.FC<AlertInstanceFormProps> = (props) => {
</Form.Item>
</>
}
{ (vals.sendType === "群聊") ?
<div hidden>
<Form.Item
name="showType"
label="展示方式"
......@@ -148,21 +146,6 @@ const WeChatForm: React.FC<AlertInstanceFormProps> = (props) => {
<Radio value='text'>文本</Radio>
</Radio.Group>
</Form.Item>
</div>
:
<>
<Form.Item
name="showType"
label="展示方式"
rules={[{required: true, message: '请选择展示方式!'}]}
>
<Radio.Group >
<Radio value='markdown'>MarkDown</Radio>
<Radio value='text'>文本</Radio>
</Radio.Group>
</Form.Item>
</>
}
<Form.Item
name="enabled"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment