37 lines
1,005 B
Elixir
37 lines
1,005 B
Elixir
defmodule PostlandWeb.ActorJSON do
|
|
use Phoenix.VerifiedRoutes, endpoint: PostlandWeb.Endpoint, router: PostlandWeb.Router
|
|
|
|
alias Postland.Accounts
|
|
|
|
def render("actor.json", _assigns) do
|
|
user = Accounts.solo_user()
|
|
|
|
%{
|
|
"@context" => [
|
|
"https://www.w3.org/ns/activitystreams",
|
|
"https://w3id.org/security/v1"
|
|
],
|
|
"id" => url(~p"/actor"),
|
|
"type" => "Person",
|
|
"preferredUsername" => user.username,
|
|
"name" => user.name,
|
|
"summary" => user.summary,
|
|
"inbox" => url(~p"/inbox"),
|
|
"outbox" => url(~p"/outbox"),
|
|
"publicKey" => %{
|
|
"id" => url(~p"/actor#main-key"),
|
|
"owner" => url(~p"/actor"),
|
|
"publicKeyPem" => user.public_key
|
|
},
|
|
"icon" => %{
|
|
"type" => "Image",
|
|
"mediaType" => "image/png",
|
|
"url" =>
|
|
if(user.icon,
|
|
do: unverified_url(PostlandWeb.Endpoint, user.icon),
|
|
else: url(~p"/images/avatar.png")
|
|
)
|
|
}
|
|
}
|
|
end
|
|
end
|