|
|
|
@ -23,9 +23,7 @@ import org.apache.dolphinscheduler.spi.utils.JSONUtils;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.codec.binary.StringUtils; |
|
|
|
|
import org.apache.http.HttpEntity; |
|
|
|
|
import org.apache.http.HttpHost; |
|
|
|
|
import org.apache.http.HttpStatus; |
|
|
|
|
import org.apache.http.client.config.RequestConfig; |
|
|
|
|
import org.apache.http.client.methods.CloseableHttpResponse; |
|
|
|
|
import org.apache.http.client.methods.HttpPost; |
|
|
|
|
import org.apache.http.impl.client.CloseableHttpClient; |
|
|
|
@ -71,11 +69,6 @@ public class FeiShuSender {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static RequestConfig getProxyConfig(String proxy, int port) { |
|
|
|
|
HttpHost httpProxy = new HttpHost(proxy, port); |
|
|
|
|
return RequestConfig.custom().setProxy(httpProxy).build(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static String textToJsonString(AlertData alertData) { |
|
|
|
|
|
|
|
|
|
Map<String, Object> items = new HashMap<>(2); |
|
|
|
@ -88,7 +81,7 @@ public class FeiShuSender {
|
|
|
|
|
return JSONUtils.toJsonString(items); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static AlertResult checkSendFeiShuSendMsgResult(String result) { |
|
|
|
|
public static AlertResult checkSendFeiShuSendMsgResult(String result) { |
|
|
|
|
AlertResult alertResult = new AlertResult(); |
|
|
|
|
alertResult.setStatus("false"); |
|
|
|
|
|
|
|
|
@ -116,12 +109,10 @@ public class FeiShuSender {
|
|
|
|
|
|
|
|
|
|
public static String formatContent(AlertData alertData) { |
|
|
|
|
if (alertData.getContent() != null) { |
|
|
|
|
List<Map> list; |
|
|
|
|
try { |
|
|
|
|
list = JSONUtils.toList(alertData.getContent(), Map.class); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
logger.error("json format exception", e); |
|
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
List<Map> list = JSONUtils.toList(alertData.getContent(), Map.class); |
|
|
|
|
if (list.isEmpty()) { |
|
|
|
|
return alertData.getTitle() + alertData.getContent(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
StringBuilder contents = new StringBuilder(100); |
|
|
|
@ -170,7 +161,7 @@ public class FeiShuSender {
|
|
|
|
|
|
|
|
|
|
int statusCode = response.getStatusLine().getStatusCode(); |
|
|
|
|
if (statusCode != HttpStatus.SC_OK) { |
|
|
|
|
logger.error("send feishu message error, return http status code: " + statusCode); |
|
|
|
|
logger.error("send feishu message error, return http status code: {} ", statusCode); |
|
|
|
|
} |
|
|
|
|
String resp; |
|
|
|
|
try { |
|
|
|
@ -180,7 +171,7 @@ public class FeiShuSender {
|
|
|
|
|
} finally { |
|
|
|
|
response.close(); |
|
|
|
|
} |
|
|
|
|
logger.info("Ding Talk send title :{} ,content :{}, resp: {}", alertData.getTitle(), alertData.getContent(), resp); |
|
|
|
|
logger.info("Fei Shu send title :{} ,content :{}, resp: {}", alertData.getTitle(), alertData.getContent(), resp); |
|
|
|
|
return resp; |
|
|
|
|
} finally { |
|
|
|
|
httpClient.close(); |
|
|
|
|