23 lines
521 B
Elixir
23 lines
521 B
Elixir
|
defmodule ClacksWeb.ActorController do
|
||
|
use ClacksWeb, :controller
|
||
|
alias Clacks.{Repo, Actor}
|
||
|
import Ecto.Query
|
||
|
|
||
|
def get(conn, %{"nickname" => nickname}) do
|
||
|
case Actor.get_by_nickanme(nickname) do
|
||
|
%Actor{local: true, data: data} ->
|
||
|
conn
|
||
|
|> put_resp_header("content-type", "application/activity+json")
|
||
|
|> json(data)
|
||
|
|
||
|
%Actor{local: false, ap_id: ap_id} ->
|
||
|
conn
|
||
|
|> redirect(external: ap_id)
|
||
|
|
||
|
_ ->
|
||
|
conn
|
||
|
|> put_status(404)
|
||
|
end
|
||
|
end
|
||
|
end
|