24 lines
672 B
Elixir
24 lines
672 B
Elixir
defmodule NullaWeb.ActivityPub.FeaturedController do
|
|
use NullaWeb, :controller
|
|
alias Nulla.Actors
|
|
alias Nulla.Notes
|
|
alias Nulla.Actors.Actor
|
|
alias NullaWeb.ActivityPub.FeaturedJSON
|
|
|
|
def index(conn, %{"username" => username}) do
|
|
domain = NullaWeb.Endpoint.host()
|
|
actor = Actors.get_actor_by(acct: "#{username}@#{domain}")
|
|
|
|
case actor do
|
|
%Actor{} = actor ->
|
|
notes = Notes.list_notes_by(actor_id: actor.id, featured: true)
|
|
|
|
conn
|
|
|> put_resp_content_type("application/activity+json")
|
|
|> send_resp(200, Jason.encode!(FeaturedJSON.index(actor, notes)))
|
|
|
|
_ ->
|
|
send_resp(conn, 404, "")
|
|
end
|
|
end
|
|
end
|