1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.Feed.FeedView do
9 alias Pleroma.Formatter
12 alias Pleroma.Web.MediaProxy
14 require Pleroma.Constants
16 def prepare_activity(activity) do
17 object = activity_object(activity)
21 data: Map.get(object, :data),
26 def most_recent_update(activities, user) do
27 (List.first(activities) || user).updated_at
28 |> NaiveDateTime.to_iso8601()
37 def last_activity(activities), do: List.last(activities)
39 def activity_object(activity), do: Object.normalize(activity)
41 def activity_title(%{data: %{"content" => content}}, opts \\ %{}) do
43 |> Formatter.truncate(opts[:max_length], opts[:omission])
47 def activity_content(%{data: %{"content" => content}}) do
49 |> String.replace(~r/[\n\r]/, "")
53 def activity_context(activity), do: activity.data["context"]
55 def attachment_href(attachment) do
61 def attachment_type(attachment) do
64 |> Map.get("mediaType")
68 with %Object{data: %{"external_url" => external_url}} <- Object.get_cached_by_ap_id(id) do