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
|
|
|
|
|
|
|
|
_ ->
|
2020-04-21 02:41:07 +00:00
|
|
|
resp(conn, 404, "Not Found")
|
2019-10-06 23:41:18 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|