diff --git a/CHANGELOG.md b/CHANGELOG.md
index b33d61819..1eb7d14cd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -58,6 +58,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Pleroma API: `POST /api/v1/pleroma/conversations/read` to mark all conversations as read
- Mastodon API: Add `/api/v1/markers` for managing timeline read markers
- Mastodon API: Add the `recipients` parameter to `GET /api/v1/conversations`
+- Configuration: `feed` option for user atom feed.
### Fixed
diff --git a/config/config.exs b/config/config.exs
index 787809b27..7e1fe2a81 100644
--- a/config/config.exs
+++ b/config/config.exs
@@ -276,6 +276,12 @@
external_user_synchronization: true,
extended_nickname_format: false
+config :pleroma, :feed,
+ post_title: %{
+ max_length: 100,
+ omission: "..."
+ }
+
config :pleroma, :markup,
# XXX - unfortunately, inline images must be enabled by default right now, because
# of custom emoji. Issue #275 discusses defanging that somehow.
diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex
index 51a9c6169..65dd251f3 100644
--- a/lib/pleroma/web/activity_pub/activity_pub.ex
+++ b/lib/pleroma/web/activity_pub/activity_pub.ex
@@ -568,7 +568,6 @@ def fetch_public_activities(opts \\ %{}, pagination \\ :keyset) do
|> fetch_activities_query(opts)
|> restrict_unlisted()
|> Pagination.fetch_paginated(opts, pagination)
- |> Enum.reverse()
end
@valid_visibilities ~w[direct unlisted public private]
diff --git a/lib/pleroma/web/feed/feed_controller.ex b/lib/pleroma/web/feed/feed_controller.ex
index d91ecef9c..d0e23007d 100644
--- a/lib/pleroma/web/feed/feed_controller.ex
+++ b/lib/pleroma/web/feed/feed_controller.ex
@@ -33,21 +33,22 @@ def feed_redirect(conn, %{"nickname" => nickname}) do
def feed(conn, %{"nickname" => nickname} = params) do
with {_, %User{} = user} <- {:fetch_user, User.get_cached_by_nickname(nickname)} do
- query_params =
- params
- |> Map.take(["max_id"])
- |> Map.put("type", ["Create"])
- |> Map.put("whole_db", true)
- |> Map.put("actor_id", user.ap_id)
-
activities =
- query_params
+ %{
+ "type" => ["Create"],
+ "whole_db" => true,
+ "actor_id" => user.ap_id
+ }
+ |> Map.merge(Map.take(params, ["max_id"]))
|> ActivityPub.fetch_public_activities()
- |> Enum.reverse()
conn
|> put_resp_content_type("application/atom+xml")
- |> render("feed.xml", user: user, activities: activities)
+ |> render("feed.xml",
+ user: user,
+ activities: activities,
+ feed_config: Pleroma.Config.get([:feed])
+ )
end
end
diff --git a/lib/pleroma/web/feed/feed_view.ex b/lib/pleroma/web/feed/feed_view.ex
index 5eef1e757..bb1332fd3 100644
--- a/lib/pleroma/web/feed/feed_view.ex
+++ b/lib/pleroma/web/feed/feed_view.ex
@@ -6,12 +6,23 @@ defmodule Pleroma.Web.Feed.FeedView do
use Phoenix.HTML
use Pleroma.Web, :view
+ alias Pleroma.Formatter
alias Pleroma.Object
alias Pleroma.User
alias Pleroma.Web.MediaProxy
require Pleroma.Constants
+ def prepare_activity(activity) do
+ object = activity_object(activity)
+
+ %{
+ activity: activity,
+ data: Map.get(object, :data),
+ object: object
+ }
+ end
+
def most_recent_update(activities, user) do
(List.first(activities) || user).updated_at
|> NaiveDateTime.to_iso8601()
@@ -23,31 +34,23 @@ def logo(user) do
|> MediaProxy.url()
end
- 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
+ content
+ |> Formatter.truncate(opts[:max_length], opts[:omission])
+ |> escape()
end
- def activity_object(activity) do
- Object.normalize(activity)
- end
-
- def activity_object_data(activity) do
- activity
- |> activity_object()
- |> Map.get(:data)
- end
-
- def activity_content(activity) do
- content = activity_object_data(activity)["content"]
-
+ def activity_content(%{data: %{"content" => content}}) do
content
|> String.replace(~r/[\n\r]/, "")
|> escape()
end
- def activity_context(activity) do
- activity.data["context"]
- end
+ def activity_context(activity), do: activity.data["context"]
def attachment_href(attachment) do
attachment["url"]
diff --git a/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex b/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex
index f2d2d3ccb..384159336 100644
--- a/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex
+++ b/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex
@@ -71,7 +71,6 @@ def public(%{assigns: %{user: user}} = conn, params) do
|> Map.put("blocking_user", user)
|> Map.put("muting_user", user)
|> ActivityPub.fetch_public_activities()
- |> Enum.reverse()
conn
|> add_link_headers(activities, %{"local" => local_only})
@@ -110,7 +109,6 @@ def hashtag(%{assigns: %{user: user}} = conn, params) do
|> Map.put("tag_all", tag_all)
|> Map.put("tag_reject", tag_reject)
|> ActivityPub.fetch_public_activities()
- |> Enum.reverse()
conn
|> add_link_headers(activities, %{"local" => local_only})
diff --git a/lib/pleroma/web/templates/feed/feed/_activity.xml.eex b/lib/pleroma/web/templates/feed/feed/_activity.xml.eex
index d1f5e903c..514eacaed 100644
--- a/lib/pleroma/web/templates/feed/feed/_activity.xml.eex
+++ b/lib/pleroma/web/templates/feed/feed/_activity.xml.eex
@@ -2,11 +2,13 @@