Don't filter 4chan for blacklist
This commit is contained in:
parent
a026fbf900
commit
bcf3ad708a
|
@ -216,7 +216,7 @@ def construct_query(query, size, use_query_string=True, tokens=False):
|
|||
return query_base
|
||||
|
||||
|
||||
def run_main_query(client, user, query, custom_query=False, index=None, size=None):
|
||||
def run_main_query(client, user, query, custom_query=False, index=None, size=None, filter=True):
|
||||
"""
|
||||
Low level helper to run an ES query.
|
||||
Accept a user to pass it to the filter, so we can
|
||||
|
@ -238,7 +238,8 @@ def run_main_query(client, user, query, custom_query=False, index=None, size=Non
|
|||
except NotFoundError as err:
|
||||
print("OpenSearch error", err)
|
||||
return err
|
||||
filter_blacklisted(user, response)
|
||||
if filter:
|
||||
filter_blacklisted(user, response)
|
||||
return response
|
||||
|
||||
|
||||
|
@ -539,6 +540,9 @@ def query_results(
|
|||
else:
|
||||
index = settings.OPENSEARCH_INDEX_MAIN
|
||||
|
||||
filter = True
|
||||
if source in settings.SAFE_SOURCES:
|
||||
filter = False
|
||||
results = run_main_query(
|
||||
client,
|
||||
request.user, # passed through run_main_query to filter_blacklisted
|
||||
|
@ -546,6 +550,7 @@ def query_results(
|
|||
custom_query=True,
|
||||
index=index,
|
||||
size=size,
|
||||
filter=filter,
|
||||
)
|
||||
if not results:
|
||||
return False
|
||||
|
@ -598,9 +603,11 @@ def query_results(
|
|||
"object_list": results_parsed,
|
||||
"card": results["hits"]["total"]["value"],
|
||||
"took": results["took"],
|
||||
"redacted": results["redacted"],
|
||||
"exemption": results["exemption"],
|
||||
}
|
||||
if "redacted" in results:
|
||||
context["redacted"] = results["redacted"]
|
||||
if "exemption" in results:
|
||||
context["exemption"] = results["exemption"]
|
||||
if query:
|
||||
context["query"] = query
|
||||
if settings.DELAY_RESULTS:
|
||||
|
|
Loading…
Reference in New Issue