philomena/lib/philomena_web/controllers/api/rss/watched_controller.ex

34 lines
764 B
Elixir
Raw Normal View History

2019-12-04 01:50:23 +01:00
defmodule PhilomenaWeb.Api.Rss.WatchedController do
2019-12-01 00:11:24 +01:00
use PhilomenaWeb, :controller
alias Philomena.Images.{Image, Query}
import Ecto.Query
def index(conn, _params) do
user = conn.assigns.current_user
filter = conn.assigns.compiled_filter
{:ok, query} = Query.compile(user, "my:watched")
images =
Image.search_records(
%{
query: %{
bool: %{
must: query,
must_not: [
filter,
%{term: %{hidden_from_users: true}}
]
}
},
sort: %{created_at: :desc}
},
conn.assigns.image_pagination,
Image |> preload(:tags)
)
conn
|> render("index.rss", images: images)
end
end