mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-28 05:57:58 +01:00
27 lines
595 B
Elixir
27 lines
595 B
Elixir
|
defmodule PhilomenaWeb.Api.Json.ProfileController do
|
||
|
use PhilomenaWeb, :controller
|
||
|
|
||
|
alias PhilomenaWeb.UserJson
|
||
|
alias Philomena.Users.User
|
||
|
alias Philomena.Repo
|
||
|
import Ecto.Query
|
||
|
|
||
|
def show(conn, %{"id" => id}) do
|
||
|
profile =
|
||
|
User
|
||
|
|> where(id: ^id)
|
||
|
|> preload([public_links: :tag, awards: :badge])
|
||
|
|> Repo.one()
|
||
|
|
||
|
cond do
|
||
|
is_nil(profile) or profile.deleted_at ->
|
||
|
conn
|
||
|
|> put_status(:not_found)
|
||
|
|> text("")
|
||
|
|
||
|
true ->
|
||
|
json(conn, %{user: UserJson.as_json(conn, profile)})
|
||
|
end
|
||
|
end
|
||
|
end
|