Skip to content

Commit

Permalink
Fix blockService null and duplicate values
Browse files Browse the repository at this point in the history
  • Loading branch information
JoKneeMo authored and JoKneeMo committed Aug 1, 2022
1 parent 99a1898 commit 042f7dd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions adguardhome/drivers/AdGuardHome_Server.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Author: JoKneeMo <https://github.com/JoKneeMo>
* Copyright: JoKneeMo <https://github.com/JoKneeMo>
* License: GPL-3.0-only
* Version: 0.1.0
* Version: 0.1.1
*/

metadata {
Expand Down Expand Up @@ -203,7 +203,13 @@ def blockService(services_string) {
List<String> currentBlocks_list = device.currentValue("blockedServices").toString().replaceAll("\\[|\\]", "").split("\\s*,\\s*")
logDebug "Currently Blocking ${currentBlocks_list.size()} Services: ${currentBlocks_list}"

def postBlockList = currentBlocks_list + services_list
def postBlockList = []
if ("${currentBlocks_list[0]}" != "") {
def dedupBlockList = services_list - currentBlocks_list
postBlockList += currentBlocks_list + dedupBlockList
} else {
postBlockList += services_list
}
logDebug "Setting ${postBlockList.size} Blocked Services: ${postBlockList}"

doHttpPostJson("/blocked_services/set", postBlockList)
Expand Down

0 comments on commit 042f7dd

Please sign in to comment.