Fix ZNC queries

This commit is contained in:
2022-08-15 17:59:09 +01:00
parent c9fe1f0b73
commit 4be21cb488
4 changed files with 41 additions and 23 deletions

View File

@@ -253,7 +253,7 @@ class DrilldownContextModal(APIView):
size = 20
nicks = None
# Create the query params from the POST arguments
mandatory = ["net", "channel", "num", "src", "index", "nick"]
mandatory = ["net", "channel", "num", "src", "index", "nick", "type"]
invalid = [None, False, "", "None"]
query_params = {k: v for k, v in request.data.items() if v}
for key in query_params:
@@ -275,6 +275,13 @@ class DrilldownContextModal(APIView):
and not query_params["type"] == "query"
):
query_params["index"] = "main"
type = None
if "type" in query_params:
type = query_params["type"]
if type == "znc":
query_params["channel"] = "*status"
# Create the query with the context helper
search_query = construct_query(
query_params["index"],
@@ -283,10 +290,16 @@ class DrilldownContextModal(APIView):
query_params["src"],
query_params["num"],
size,
type=type,
nicks=nicks,
)
annotate = False
if query_params["src"] == "irc":
if query_params["type"] in ["query", "notice", "msg", "highlight"]:
annotate = True
results = query_results(
request, query_params, annotate=True, custom_query=search_query
request, query_params, annotate=annotate, custom_query=search_query
)
if "message" in results:
return render(request, self.template_name, results)