logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

embed_view.ex (1974B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Web.EmbedView do
  5. use Pleroma.Web, :view
  6. alias Calendar.Strftime
  7. alias Pleroma.Activity
  8. alias Pleroma.Emoji.Formatter
  9. alias Pleroma.Object
  10. alias Pleroma.User
  11. alias Pleroma.Web.Gettext
  12. alias Pleroma.Web.MediaProxy
  13. alias Pleroma.Web.Metadata.Utils
  14. alias Pleroma.Web.Router.Helpers
  15. use Phoenix.HTML
  16. defdelegate full_nickname(user), to: User
  17. @media_types ["image", "audio", "video"]
  18. defp fetch_media_type(%{"mediaType" => mediaType}) do
  19. Utils.fetch_media_type(@media_types, mediaType)
  20. end
  21. defp open_content? do
  22. Pleroma.Config.get(
  23. [:frontend_configurations, :collapse_message_with_subjects],
  24. true
  25. )
  26. end
  27. defp status_title(%Activity{object: %Object{data: %{"name" => name}}}) when is_binary(name),
  28. do: name
  29. defp status_title(%Activity{object: %Object{data: %{"summary" => summary}}})
  30. when is_binary(summary),
  31. do: summary
  32. defp status_title(_), do: nil
  33. defp activity_content(%Activity{object: %Object{data: %{"content" => content}}}) do
  34. content |> Pleroma.HTML.filter_tags() |> raw()
  35. end
  36. defp activity_content(_), do: nil
  37. defp activity_url(%User{local: true}, activity) do
  38. Helpers.o_status_url(Pleroma.Web.Endpoint, :notice, activity)
  39. end
  40. defp activity_url(%User{local: false}, %Activity{object: %Object{data: data}}) do
  41. data["url"] || data["external_url"] || data["id"]
  42. end
  43. defp attachments(%Activity{object: %Object{data: %{"attachment" => attachments}}}) do
  44. attachments
  45. end
  46. defp sensitive?(%Activity{object: %Object{data: %{"sensitive" => sensitive}}}) do
  47. sensitive
  48. end
  49. defp published(%Activity{object: %Object{data: %{"published" => published}}}) do
  50. published
  51. |> NaiveDateTime.from_iso8601!()
  52. |> Strftime.strftime!("%B %d, %Y, %l:%M %p")
  53. end
  54. end