25 lines
607 B
Elixir
25 lines
607 B
Elixir
|
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
|