static fe: use a generic activity representer to render activities
[akkoma] / lib / pleroma / web / static_fe / static_fe_controller.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.StaticFE.StaticFEController do
6 use Pleroma.Web, :controller
7
8 alias Pleroma.Web.StaticFE.ActivityRepresenter
9
10 require Logger
11
12 def show_notice(conn, %{"notice_id" => notice_id}) do
13 with {:ok, data} <- ActivityRepresenter.represent(notice_id) do
14 conn
15 |> put_layout(:static_fe)
16 |> put_status(200)
17 |> put_view(Pleroma.Web.StaticFE.StaticFEView)
18 |> render("notice.html", data)
19 else
20 _ ->
21 conn
22 |> put_status(404)
23 |> text("Not found")
24 end
25 end
26
27 def show(%{path_info: ["notice", notice_id]} = conn, _params),
28 do: show_notice(conn, %{"notice_id" => notice_id})
29
30 # Fallback for unhandled types
31 def show(conn, _params) do
32 conn
33 |> put_status(404)
34 |> text("Not found")
35 end
36 end