mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-24 04:27:59 +01:00
21 lines
362 B
Elixir
Executable file
21 lines
362 B
Elixir
Executable file
defmodule PhilomenaWeb.LinksJson do
|
|
|
|
def as_json(_conn, %{public: false}), do: nil
|
|
|
|
def as_json(_conn, link) do
|
|
%{
|
|
user_id: link.user_id,
|
|
created_at: link.created_at,
|
|
state: link.aasm_state,
|
|
tag_id: tag_id(link.tag)
|
|
}
|
|
end
|
|
|
|
defp tag_id(nil) do
|
|
nil
|
|
end
|
|
|
|
defp tag_id(tag) do
|
|
tag.id
|
|
end
|
|
end
|