projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Pagination: Don't be dos'd by random parameters.
[akkoma]
/
lib
/
pleroma
/
web
/
feed
/
feed_view.ex
diff --git
a/lib/pleroma/web/feed/feed_view.ex
b/lib/pleroma/web/feed/feed_view.ex
index 2e7db1ebbd3966ac4cee2ca1bbd0b8ef813683b1..bc0114e26fc980ac235ad387cb1dd4c32773e313 100644
(file)
--- a/
lib/pleroma/web/feed/feed_view.ex
+++ b/
lib/pleroma/web/feed/feed_view.ex
@@
-1,5
+1,5
@@
# Pleroma: A lightweight social networking server
# Pleroma: A lightweight social networking server
-# Copyright © 2017-20
19
Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-20
20
Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Feed.FeedView do
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Feed.FeedView do
@@
-22,16
+22,27
@@
defmodule Pleroma.Web.Feed.FeedView do
def pub_date(%DateTime{} = date), do: Timex.format!(date, "{RFC822}")
def pub_date(%DateTime{} = date), do: Timex.format!(date, "{RFC822}")
- def prepare_activity(activity) do
- object = activity_object(activity)
+ def prepare_activity(activity, opts \\ []) do
+ object = Object.normalize(activity, fetch: false)
+
+ actor =
+ if opts[:actor] do
+ Pleroma.User.get_cached_by_ap_id(activity.actor)
+ end
%{
activity: activity,
data: Map.get(object, :data),
%{
activity: activity,
data: Map.get(object, :data),
- object: object
+ actor: actor
}
end
}
end
+ def most_recent_update(activities) do
+ with %{updated_at: updated_at} <- List.first(activities) do
+ NaiveDateTime.to_iso8601(updated_at)
+ end
+ end
+
def most_recent_update(activities, user) do
(List.first(activities) || user).updated_at
|> NaiveDateTime.to_iso8601()
def most_recent_update(activities, user) do
(List.first(activities) || user).updated_at
|> NaiveDateTime.to_iso8601()
@@
-40,7
+51,7
@@
defmodule Pleroma.Web.Feed.FeedView do
def feed_logo do
case Pleroma.Config.get([:feed, :logo]) do
nil ->
def feed_logo do
case Pleroma.Config.get([:feed, :logo]) do
nil ->
- "#{Pleroma.Web.base_url()}/static/logo.
pn
g"
+ "#{Pleroma.Web.base_url()}/static/logo.
sv
g"
logo ->
"#{Pleroma.Web.base_url()}#{logo}"
logo ->
"#{Pleroma.Web.base_url()}#{logo}"
@@
-56,9
+67,7
@@
defmodule Pleroma.Web.Feed.FeedView do
def last_activity(activities), do: List.last(activities)
def last_activity(activities), do: List.last(activities)
- def activity_object(activity), do: Object.normalize(activity)
-
- def activity_title(%{data: %{"content" => content}}, opts \\ %{}) do
+ def activity_title(%{"content" => content}, opts \\ %{}) do
content
|> Pleroma.Web.Metadata.Utils.scrub_html()
|> Pleroma.Emoji.Formatter.demojify()
content
|> Pleroma.Web.Metadata.Utils.scrub_html()
|> Pleroma.Emoji.Formatter.demojify()
@@
-66,7
+75,7
@@
defmodule Pleroma.Web.Feed.FeedView do
|> escape()
end
|> escape()
end
- def activity_content(%{
data: %{"content" => content}
}) do
+ def activity_content(%{
"content" => content
}) do
content
|> String.replace(~r/[\n\r]/, "")
|> escape()
content
|> String.replace(~r/[\n\r]/, "")
|> escape()
@@
-74,7
+83,7
@@
defmodule Pleroma.Web.Feed.FeedView do
def activity_content(_), do: ""
def activity_content(_), do: ""
- def activity_context(activity), do:
activity.data["context"]
+ def activity_context(activity), do:
escape(activity.data["context"])
def attachment_href(attachment) do
attachment["url"]
def attachment_href(attachment) do
attachment["url"]