mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-12-18 15:08:00 +01:00
26 lines
528 B
Elixir
26 lines
528 B
Elixir
defmodule PhilomenaWeb.Api.Json.ImageController do
|
|
use PhilomenaWeb, :controller
|
|
|
|
alias PhilomenaWeb.ImageJson
|
|
alias Philomena.Images.Image
|
|
alias Philomena.Repo
|
|
import Ecto.Query
|
|
|
|
def show(conn, %{"id" => id}) do
|
|
image =
|
|
Image
|
|
|> where(id: ^id)
|
|
|> preload([:tags, :user, :intensity])
|
|
|> Repo.one()
|
|
|
|
case image do
|
|
nil ->
|
|
conn
|
|
|> put_status(:not_found)
|
|
|> text("")
|
|
|
|
_ ->
|
|
json(conn, %{image: ImageJson.as_json(conn, image)})
|
|
end
|
|
end
|
|
end
|