Skip to content

feat: allow webhook removal on config import#693

Draft
iProdigy wants to merge 1 commit intopajlads:masterfrom
iProdigy:feature/config-import-remove-webhooks
Draft

feat: allow webhook removal on config import#693
iProdigy wants to merge 1 commit intopajlads:masterfrom
iProdigy:feature/config-import-remove-webhooks

Conversation

@iProdigy
Copy link
Copy Markdown
Member

Closes #659

@iProdigy
Copy link
Copy Markdown
Member Author

do we care about making the hostname comparison case-insensitive?

Subject: [PATCH] fix: use case-insensitive host comparison
---
Index: src/main/java/dinkplugin/SettingsManager.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/main/java/dinkplugin/SettingsManager.java b/src/main/java/dinkplugin/SettingsManager.java
--- a/src/main/java/dinkplugin/SettingsManager.java	
+++ b/src/main/java/dinkplugin/SettingsManager.java	
@@ -614,10 +614,13 @@
         if (!(input instanceof Iterable)) return false;
 
         // read deleted urls
-        Set<String> deletedUrls = new HashSet<>();
+        Set<HttpUrl> deletedUrls = new HashSet<>();
         for (Object o : (Iterable<?>) input) {
             if (o instanceof String) {
-                deletedUrls.add((String) o);
+                var url = HttpUrl.parse((String) o);
+                if (url != null) {
+                    deletedUrls.add(url);
+                }
             }
         }
 
@@ -628,6 +631,8 @@
             String configValue = configManager.getConfiguration(CONFIG_GROUP, webhookConfigKey);
             boolean[] filtered = { false };
             String updatedValue = ConfigUtil.readDelimited(configValue)
+                .map(HttpUrl::parse)
+                .filter(Objects::nonNull)
                 .filter(url -> {
                     if (deletedUrls.contains(url)) {
                         filtered[0] = true;
@@ -635,6 +640,7 @@
                     }
                     return true;
                 })
+                .map(HttpUrl::toString)
                 .collect(Collectors.joining("\n"));
             if (filtered[0]) {
                 configManager.setConfiguration(CONFIG_GROUP, webhookConfigKey, updatedValue);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Import Policy to Export Command & Dynamic Config URL

1 participant