Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix enterprise wechat push display content is too cumbersome #1149

Merged
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.hertzbeat.common.constants.CommonConstants;
import org.dromara.hertzbeat.common.entity.alerter.Alert;
import org.dromara.hertzbeat.common.entity.manager.NoticeReceiver;
import org.dromara.hertzbeat.common.util.JsonUtil;
Expand All @@ -16,6 +17,8 @@
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
Expand Down Expand Up @@ -60,7 +63,7 @@ public void send(NoticeReceiver receiver, Alert alert) throws AlertNoticeExcepti
if (Objects.nonNull(entityResponse.getBody())) {
String accessToken = entityResponse.getBody().getAccessToken();
WeChatAppDTO.TextDTO textDTO = new WeChatAppDTO.TextDTO();
textDTO.setContent(JsonUtil.toJson(alert));
textDTO.setContent(generateContent(alert));
WeChatAppDTO weChatAppDTO = WeChatAppDTO.builder()
.toUser(DEFAULT_ALL)
.msgType(DEFAULT_TYPE)
Expand All @@ -86,4 +89,13 @@ public byte type() {
return 10;
}


private String generateContent(Alert alert){
Map<String,Object> contentMap=new HashMap<>();
tomsun28 marked this conversation as resolved.
Show resolved Hide resolved
contentMap.put("alertDefineId",alert.getAlertDefineId());
contentMap.put("content",alert.getContent());
contentMap.put("monitorName",alert.getTags().get(CommonConstants.TAG_MONITOR_NAME));
return JSON.toJSONString(contentMap);
}

}
Loading