From 2a3b1b82b3c632e6b1d7a81cbdf6cfcc8529d43c Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Wed, 3 Aug 2022 07:20:30 +0100 Subject: [PATCH] Prevent multiple matches to exemption rules incrementing the counter --- core/lib/opensearch.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/core/lib/opensearch.py b/core/lib/opensearch.py index c7e0c45..6dfa918 100644 --- a/core/lib/opensearch.py +++ b/core/lib/opensearch.py @@ -96,6 +96,12 @@ def filter_blacklisted(user, response): if blacklisted_item == str(content): # Remove the item if item in response["hits"]["hits"]: + # Let the UI know something was redacted + if ( + "exemption" + not in response["hits"]["hits"][index]["_source"] + ): + response["redacted"] += 1 # Anonymous if user.is_anonymous: response["hits"]["hits"].remove(item) @@ -107,9 +113,6 @@ def filter_blacklisted(user, response): "exemption" ] = True - # Let the UI know something was redacted - response["redacted"] += 1 - def run_main_query(client, user, query, custom_query=False, index=None, size=None): """ @@ -199,7 +202,7 @@ def query_results(request, size=None): # Split the timestamp into date and time if "ts" not in element: - if "time" in element: # will fix data later + if "time" in element: # will fix data later ts = element["time"] del element["time"] element["ts"] = ts