Change structure
This commit is contained in:
parent
01c2c57933
commit
ddfb58c041
16 changed files with 153 additions and 66 deletions
32
lib/nulla_web/controllers/web/actor_controller.ex
Normal file
32
lib/nulla_web/controllers/web/actor_controller.ex
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue