Use compile with opts for comment queries

This commit is contained in:
Liam 2024-07-13 14:38:20 -04:00
parent 097158bbbb
commit fc2ab285c7
3 changed files with 5 additions and 4 deletions

View file

@ -92,7 +92,8 @@ defmodule Philomena.Comments.Query do
|> Parser.parse(query_string, context)
end
def compile(user, query_string) do
def compile(query_string, opts \\ []) do
user = Keyword.get(opts, :user)
query_string = query_string || ""
case user do

View file

@ -10,7 +10,7 @@ defmodule PhilomenaWeb.Api.Json.Search.CommentController do
user = conn.assigns.current_user
filter = conn.assigns.current_filter
case Query.compile(user, params["q"] || "") do
case Query.compile(params["q"], user: user) do
{:ok, query} ->
comments =
Comment

View file

@ -13,8 +13,8 @@ defmodule PhilomenaWeb.CommentController do
conn = Map.put(conn, :params, params)
user = conn.assigns.current_user
user
|> Query.compile(cq)
cq
|> Query.compile(user: user)
|> render_index(conn, user)
end