1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 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 def show(conn, %{"id" => id}) do
15 with %Activity{local: true} = activity <-
16 Activity.get_by_id_with_object(id),
17 true <- Visibility.public?(activity.object) do
18 {:ok, author} = User.get_or_fetch(activity.object.data["actor"])
21 |> delete_resp_header("x-frame-options")
22 |> delete_resp_header("content-security-policy")
23 |> render("show.html",
25 author: User.sanitize_html(author),
26 counts: get_counts(activity)
31 defp get_counts(%Activity{} = activity) do
32 %Object{data: data} = Object.normalize(activity, fetch: false)
35 likes: Map.get(data, "like_count", 0),
36 replies: Map.get(data, "repliesCount", 0),
37 announces: Map.get(data, "announcement_count", 0)