wankai123 commented on code in PR #11137:
URL: https://github.com/apache/skywalking/pull/11137#discussion_r1275944295


##########
oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/discord/DiscordHookCallback.java:
##########
@@ -43,17 +44,28 @@ public class DiscordHookCallback extends HttpAlarmCallback {
      */
     @Override
     public void doAlarm(List<AlarmMessage> alarmMessages) throws Exception {
-        final var discordSettings = alarmRulesWatcher.getDiscordSettings();
-        if (discordSettings == null || 
discordSettings.getWebhooks().isEmpty()) {
+        Map<String, DiscordSettings> settingsMap = 
alarmRulesWatcher.getDiscordSettings();
+        if (settingsMap == null || settingsMap.isEmpty()) {
             return;
         }
-        for (final var webHookUrl : discordSettings.getWebhooks()) {
-            for (final var alarmMessage : alarmMessages) {
-                final var content = String.format(
-                        discordSettings.getTextTemplate(),
+
+        Map<String, List<AlarmMessage>> groupedMessages = 
groupMessagesByHook(alarmMessages);
+        for (Map.Entry<String, List<AlarmMessage>> entry : 
groupedMessages.entrySet()) {
+            var hookName = entry.getKey();
+            var messages = entry.getValue();
+            var setting = settingsMap.get(hookName);
+            if (setting == null || 
CollectionUtils.isEmpty(setting.getWebhooks()) || CollectionUtils.isEmpty(
+                messages)) {
+                continue;
+            }

Review Comment:
   Added



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to