Commit 19a0ae6a authored by zhu-mingye's avatar zhu-mingye

fixbug feishu alert when choose @all sendMsg failed

parent 2f47610f
...@@ -72,7 +72,7 @@ public final class FeiShuSender { ...@@ -72,7 +72,7 @@ public final class FeiShuSender {
String jsonResult =""; String jsonResult ="";
byte[] byt = StringUtils.getBytesUtf8(formatContent(alertMsg)); byte[] byt = StringUtils.getBytesUtf8(formatContent(alertMsg));
String contentResult = StringUtils.newStringUtf8(byt); String contentResult = StringUtils.newStringUtf8(byt);
String userIdsToText = mkUserIdsToText(atUserIds); String userIdsToText = mkUserIds(org.apache.commons.lang3.StringUtils.isBlank(atUserIds)? "all": atUserIds);
if (StringUtils.equals(ShowType.TEXT.getValue(), msgType)) { if (StringUtils.equals(ShowType.TEXT.getValue(), msgType)) {
jsonResult = FeiShuConstants.FEI_SHU_TEXT_TEMPLATE.replace(MSG_TYPE_REGX, msgType) jsonResult = FeiShuConstants.FEI_SHU_TEXT_TEMPLATE.replace(MSG_TYPE_REGX, msgType)
.replace(MSG_RESULT_REGX, contentResult).replace(FEI_SHU_USER_REGX, userIdsToText).replaceAll("/n", "\\\\n"); .replace(MSG_RESULT_REGX, contentResult).replace(FEI_SHU_USER_REGX, userIdsToText).replaceAll("/n", "\\\\n");
...@@ -84,16 +84,9 @@ public final class FeiShuSender { ...@@ -84,16 +84,9 @@ public final class FeiShuSender {
return jsonResult; return jsonResult;
} }
private String mkUserIdsToText(String users){ private String mkUserIds(String users){
String userIdsToText=""; String userIdsToText="";
String[] userList = users.split(","); String[] userList = users.split(",");
if (org.apache.commons.lang3.StringUtils.isEmpty(users) && Boolean.TRUE.equals(atAll)) {
if (msgType.equals(ShowType.TEXT.getValue())) {
userIdsToText="<at user_id=\\\"all\\\">所有人</at>";
}else{
userIdsToText="{\"tag\":\"at\",\"user_id\":\"all\",\"user_name\":\"所有人\"}";
}
} else {
if (msgType.equals(ShowType.TEXT.getValue())) { if (msgType.equals(ShowType.TEXT.getValue())) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (String user : userList) { for (String user : userList) {
...@@ -108,8 +101,6 @@ public final class FeiShuSender { ...@@ -108,8 +101,6 @@ public final class FeiShuSender {
sb.deleteCharAt(sb.length()-1); sb.deleteCharAt(sb.length()-1);
userIdsToText = sb.toString(); userIdsToText = sb.toString();
} }
}
return userIdsToText; return userIdsToText;
} }
......
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