clacks/lib/clacks_web/controllers/activites_controller.ex

25 lines
607 B
Elixir
Raw Normal View History

2019-10-06 23:41:18 +00:00
defmodule ClacksWeb.ActivitiesController do
use ClacksWeb, :controller
alias Clacks.{ActivityPub, Activity}
alias ClacksWeb.Router.Helpers, as: Routes
alias ClacksWeb.Endpoint
def get(conn, _params) do
ap_id = current_url(conn, %{})
case Activity.get_by_ap_id(ap_id) do
%Activity{local: true, id: id, data: data} ->
case conn.assigns[:format] do
"activity+json" ->
json(conn, data)
"html" ->
redirect(conn, to: Routes.frontend_path(Endpoint, :status, id))
end
_ ->
put_status(conn, 404)
end
end
end