|
@@ -24,6 +24,8 @@ import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
import org.apache.http.util.EntityUtils;
|
|
|
import org.apache.http.util.TextUtils;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.InitializingBean;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.util.Pair;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
@@ -32,7 +34,7 @@ import java.util.*;
|
|
|
|
|
|
@Component
|
|
|
@Slf4j
|
|
|
-public class FeishuMessageSender {
|
|
|
+public class FeishuMessageSender implements InitializingBean {
|
|
|
|
|
|
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(FeishuMessageSender.class);
|
|
|
|
|
@@ -40,6 +42,16 @@ public class FeishuMessageSender {
|
|
|
|
|
|
private static final CloseableHttpClient client = HttpPoolFactory.defaultPool();
|
|
|
|
|
|
+ private static String staticEnv;
|
|
|
+
|
|
|
+ @Value("${spring.profiles.active:prod}")
|
|
|
+ private String env;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void afterPropertiesSet() throws Exception {
|
|
|
+ FeishuMessageSender.staticEnv = env;
|
|
|
+ }
|
|
|
+
|
|
|
public void sendChat(String chatId, String title, Map<String, String> infos) {
|
|
|
sendChat(chatId, null, title, infos);
|
|
|
}
|
|
@@ -73,6 +85,9 @@ public class FeishuMessageSender {
|
|
|
|
|
|
public static void sendWebHookMessage(String robotId, String msg) {
|
|
|
// 使用自定义群机器人webhook方式,支持外部群
|
|
|
+ if (!"prod".equals(staticEnv)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
String webhookUrl = webHookUrl + robotId;
|
|
|
String hrc = request(msg, webhookUrl);
|
|
|
if (hrc == null) {
|