Fix hashing with 4chan
This commit is contained in:
@@ -211,11 +211,19 @@ def hash_list(user, data, hash_keys=False):
|
||||
r.hmset(cache, hash_table)
|
||||
|
||||
|
||||
def hash_lookup(user, data_dict):
|
||||
def hash_lookup(user, data_dict, supplementary_data=None):
|
||||
cache = "cache.hash"
|
||||
hash_list = SortedSet()
|
||||
denied = []
|
||||
for key, value in list(data_dict.items()):
|
||||
print("DATA DICT", data_dict)
|
||||
if "source" in data_dict:
|
||||
if data_dict["source"] in settings.SAFE_SOURCES:
|
||||
continue
|
||||
if supplementary_data:
|
||||
if "source" in supplementary_data:
|
||||
if supplementary_data["source"] in settings.SAFE_SOURCES:
|
||||
continue
|
||||
if key in settings.SEARCH_FIELDS_DENY:
|
||||
if not user.has_perm("core.bypass_hashing"):
|
||||
data_dict[key] = SearchDenied(key=key, value=data_dict[key])
|
||||
|
||||
@@ -374,13 +374,14 @@ class DrilldownContextModal(APIView):
|
||||
return render(request, self.template_name, results)
|
||||
|
||||
if settings.HASHING: # we probably want to see the tokens
|
||||
if not request.user.has_perm("core.bypass_hashing"):
|
||||
for index, item in enumerate(results["object_list"]):
|
||||
if "tokens" in item:
|
||||
results["object_list"][index]["msg"] = results["object_list"][
|
||||
index
|
||||
].pop("tokens")
|
||||
# item["msg"] = item.pop("tokens")
|
||||
if query_params["src"] not in settings.SAFE_SOURCES:
|
||||
if not request.user.has_perm("core.bypass_hashing"):
|
||||
for index, item in enumerate(results["object_list"]):
|
||||
if "tokens" in item:
|
||||
results["object_list"][index]["msg"] = results["object_list"][
|
||||
index
|
||||
].pop("tokens")
|
||||
# item["msg"] = item.pop("tokens")
|
||||
|
||||
# Make the time nicer
|
||||
# for index, item in enumerate(results["object_list"]):
|
||||
|
||||
Reference in New Issue
Block a user