Properly handle redactions

This commit is contained in:
2022-08-03 07:20:30 +01:00
parent 2a3b1b82b3
commit b2c009080d
2 changed files with 13 additions and 13 deletions

View File

@@ -104,15 +104,19 @@ def filter_blacklisted(user, response):
response["redacted"] += 1
# Anonymous
if user.is_anonymous:
response["hits"]["hits"].remove(item)
# Just set it to none so the index is not off
response["hits"]["hits"][index] = None
else:
if not user.is_superuser:
response["hits"]["hits"].remove(item)
response["hits"]["hits"][index] = None
else:
response["hits"]["hits"][index]["_source"][
"exemption"
] = True
# Actually get rid of all the things we set to None
response["hits"]["hits"] = [hit for hit in response["hits"]["hits"] if hit]
def run_main_query(client, user, query, custom_query=False, index=None, size=None):
"""