nulla/lib/nulla_web/controllers/relation_json.ex
2025-07-04 10:25:40 +02:00

35 lines
918 B
Elixir

defmodule NullaWeb.RelationJSON do
alias Nulla.Relations.Relation
@doc """
Renders a list of relations.
"""
def index(%{relations: relations}) do
%{data: for(relation <- relations, do: data(relation))}
end
@doc """
Renders a single relation.
"""
def show(%{relation: relation}) do
%{data: data(relation)}
end
defp data(%Relation{} = relation) do
%{
id: relation.id,
following: relation.following,
followed_by: relation.followed_by,
showing_replies: relation.showing_replies,
showings_reblogs: relation.showings_reblogs,
notifying: relation.notifying,
muting: relation.muting,
muting_notifications: relation.muting_notifications,
blocking: relation.blocking,
blocked_by: relation.blocked_by,
domain_blocking: relation.domain_blocking,
requested: relation.requested,
note: relation.note
}
end
end