Looks like source_data is on user directly now.
[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 alias Pleroma.Web.StaticFE.UserRepresenter
10
11 require Logger
12
13 def show_notice(conn, %{"notice_id" => notice_id}) do
14 with {:ok, data} <- ActivityRepresenter.represent(notice_id) do
15 conn
16 |> put_layout(:static_fe)
17 |> put_status(200)
18 |> put_view(Pleroma.Web.StaticFE.StaticFEView)
19 |> render("notice.html", %{data: data})
20 else
21 _ ->
22 conn
23 |> put_status(404)
24 |> text("Not found")
25 end
26 end
27
28 def show_user(conn, %{"username_or_id" => username_or_id}) do
29 with {:ok, data} <- UserRepresenter.represent(username_or_id) do
30 conn
31 |> put_layout(:static_fe)
32 |> put_status(200)
33 |> put_view(Pleroma.Web.StaticFE.StaticFEView)
34 |> render("profile.html", %{data: data})
35 else
36 _ ->
37 conn
38 |> put_status(404)
39 |> text("Not found")
40 end
41 end
42
43 def show(%{path_info: ["notice", notice_id]} = conn, _params),
44 do: show_notice(conn, %{"notice_id" => notice_id})
45
46 def show(%{path_info: ["users", user_id]} = conn, _params),
47 do: show_user(conn, %{"username_or_id" => user_id})
48
49 def show(%{path_info: [user_id]} = conn, _params),
50 do: show_user(conn, %{"username_or_id" => user_id})
51
52 # Fallback for unhandled types
53 def show(conn, _params) do
54 conn
55 |> put_status(404)
56 |> text("Not found")
57 end
58 end