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

49 lines
1.2 KiB
Elixir

defmodule NullaWeb.ActorJSON do
alias Nulla.Actors.Actor
@doc """
Renders a list of actors.
"""
def index(%{actors: actors}) do
%{data: for(actor <- actors, do: data(actor))}
end
@doc """
Renders a single actor.
"""
def show(%{actor: actor}) do
%{data: data(actor)}
end
defp data(%Actor{} = actor) do
%{
id: actor.id,
acct: actor.acct,
ap_id: actor.ap_id,
type: actor.type,
following: actor.following,
followers: actor.followers,
inbox: actor.inbox,
outbox: actor.outbox,
featured: actor.featured,
featuredTags: actor.featuredTags,
preferredUsername: actor.preferredUsername,
name: actor.name,
summary: actor.summary,
url: actor.url,
manuallyApprovesFollowers: actor.manuallyApprovesFollowers,
discoverable: actor.discoverable,
indexable: actor.indexable,
published: actor.published,
memorial: actor.memorial,
publicKey: actor.publicKey,
tag: actor.tag,
attachment: actor.attachment,
endpoints: actor.endpoints,
icon: actor.icon,
image: actor.image,
vcard_bday: actor.vcard_bday,
vcard_Address: actor.vcard_Address
}
end
end