You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2021/04/27 14:32:21 UTC

[GitHub] [skywalking] YunfengGao commented on a change in pull request #6860: fix spelling errors(rebootName -> robotName) in WeLinkAlarm.

YunfengGao commented on a change in pull request #6860:
URL: https://github.com/apache/skywalking/pull/6860#discussion_r621267879



##########
File path: oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/RulesReader.java
##########
@@ -257,28 +261,24 @@ private void readFeishuConfig(Rules rules) {
     /**
      * Read WeLink hook config into {@link WeLinkSettings}
      */
+    @SuppressWarnings("unchecked")
     private void readWeLinkConfig(Rules rules) {
-        Map welinkConfig = (Map) yamlData.get("welinkHooks");
-        if (welinkConfig != null) {
-            WeLinkSettings welinkSettings = new WeLinkSettings();
-            Object textTemplate = welinkConfig.getOrDefault("textTemplate", "");
-            welinkSettings.setTextTemplate((String) textTemplate);
-            List<Map<String, Object>> welinkWebHooks = (List<Map<String, Object>>) welinkConfig.get("webhooks");
-            if (welinkWebHooks != null) {
-                welinkWebHooks.forEach(welinkWebhook -> {
-                    String clientId = (String) welinkWebhook.getOrDefault("client_id", "");
-                    String clientSecret = (String) welinkWebhook.getOrDefault("client_secret", "");
-                    String accessTokenUrl = (String) welinkWebhook.getOrDefault("access_token_url", "");
-                    String messageUrl = (String) welinkWebhook.getOrDefault("message_url", "");
-                    String groupIds = (String) welinkWebhook.getOrDefault("group_ids", "");
-                    String rebootName = (String) welinkWebhook.getOrDefault("robot_name", "reboot");
-                    welinkSettings.getWebhooks()
-                                  .add(new WeLinkSettings.WebHookUrl(clientId, clientSecret, accessTokenUrl, messageUrl,
-                                                                     rebootName, groupIds
-                                  ));
-                });
-            }
-            rules.setWelinks(welinkSettings);
+        Map<String, Object> welinkConfig = (Map<String, Object>) yamlData.getOrDefault(
+            "welinkHooks",
+            Collections.EMPTY_MAP

Review comment:
       To reduce one "if judgment" for code readability.It is equivalent before and after modification




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org