1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.EmbedController do
6 use Pleroma.Web, :controller
12 alias Pleroma.Web.ActivityPub.Visibility
14 plug(:put_layout, :embed)
16 def show(conn, %{"id" => id}) do
17 with %Activity{local: true} = activity <-
18 Activity.get_by_id_with_object(id),
19 true <- Visibility.is_public?(activity.object) do
20 {:ok, author} = User.get_or_fetch(activity.object.data["actor"])
23 |> delete_resp_header("x-frame-options")
24 |> delete_resp_header("content-security-policy")
25 |> render("show.html",
27 author: User.sanitize_html(author),
28 counts: get_counts(activity)
33 defp get_counts(%Activity{} = activity) do
34 %Object{data: data} = Object.normalize(activity)
37 likes: Map.get(data, "like_count", 0),
38 replies: Map.get(data, "repliesCount", 0),
39 announces: Map.get(data, "announcement_count", 0)