clacks/lib/clacks_web/controllers/actor_controller.ex

23 lines
521 B
Elixir
Raw Normal View History

2019-10-01 02:26:08 +00:00
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