2024-09-22 00:16:10 +00:00
|
|
|
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,
|
2024-10-26 17:32:31 +00:00
|
|
|
"name" => user.name,
|
|
|
|
|
"summary" => user.summary,
|
2024-09-22 00:16:10 +00:00
|
|
|
"inbox" => url(~p"/inbox"),
|
2024-09-26 01:45:10 +00:00
|
|
|
"outbox" => url(~p"/outbox"),
|
2024-09-22 00:16:10 +00:00
|
|
|
"publicKey" => %{
|
|
|
|
|
"id" => url(~p"/actor#main-key"),
|
|
|
|
|
"owner" => url(~p"/actor"),
|
|
|
|
|
"publicKeyPem" => user.public_key
|
2024-10-16 15:30:23 +00:00
|
|
|
},
|
|
|
|
|
"icon" => %{
|
|
|
|
|
"type" => "Image",
|
|
|
|
|
"mediaType" => "image/png",
|
2024-10-26 21:51:05 +00:00
|
|
|
"url" =>
|
|
|
|
|
if(user.icon,
|
|
|
|
|
do: unverified_url(PostlandWeb.Endpoint, user.icon),
|
|
|
|
|
else: url(~p"/images/avatar.png")
|
|
|
|
|
)
|
2024-09-22 00:16:10 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
end
|