Change structure

This commit is contained in:
Mirai Kumiko 2025-07-01 10:15:06 +02:00
parent 01c2c57933
commit ddfb58c041
Signed by: miraikumiko
GPG key ID: 3F178B1B5E0CB278
16 changed files with 153 additions and 66 deletions

View file

@ -0,0 +1,32 @@
defmodule NullaWeb.Web.ActorController do
use NullaWeb, :controller
alias Nulla.Models.Actor
alias Nulla.Models.Relation
alias Nulla.Models.Note
def show(conn, %{"username" => username}) do
domain = NullaWeb.Endpoint.host()
case Actor.get_actor(preferredUsername: username, domain: domain) do
nil ->
conn
|> put_status(:not_found)
|> json(%{error: "Not Found"})
%Actor{} = actor ->
following = Relation.count_following(actor.id)
followers = Relation.count_followers(actor.id)
notes = Note.get_latest_notes(actor.id)
render(
conn,
:show,
actor: actor,
following: following,
followers: followers,
notes: notes,
layout: false
)
end
end
end