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.EmbedView do
8 alias Calendar.Strftime
10 alias Pleroma.Emoji.Formatter
13 alias Pleroma.Web.Gettext
14 alias Pleroma.Web.MediaProxy
15 alias Pleroma.Web.Metadata.Utils
16 alias Pleroma.Web.Router.Helpers
20 defdelegate full_nickname(user), to: User
22 @media_types ["image", "audio", "video"]
24 defp fetch_media_type(%{"mediaType" => mediaType}) do
25 Utils.fetch_media_type(@media_types, mediaType)
30 [:frontend_configurations, :collapse_message_with_subjects],
35 defp status_title(%Activity{object: %Object{data: %{"name" => name}}}) when is_binary(name),
38 defp status_title(%Activity{object: %Object{data: %{"summary" => summary}}})
39 when is_binary(summary),
42 defp status_title(_), do: nil
44 defp activity_content(%Activity{object: %Object{data: %{"content" => content}}}) do
45 content |> Pleroma.HTML.filter_tags() |> raw()
48 defp activity_content(_), do: nil
50 defp activity_url(%User{local: true}, activity) do
51 Helpers.o_status_url(Pleroma.Web.Endpoint, :notice, activity)
54 defp activity_url(%User{local: false}, %Activity{object: %Object{data: data}}) do
55 data["url"] || data["external_url"] || data["id"]
58 defp attachments(%Activity{object: %Object{data: %{"attachment" => attachments}}}) do
62 defp sensitive?(%Activity{object: %Object{data: %{"sensitive" => sensitive}}}) do
66 defp published(%Activity{object: %Object{data: %{"published" => published}}}) do
68 |> NaiveDateTime.from_iso8601!()
69 |> Strftime.strftime!("%B %d, %Y, %l:%M %p")