summaryrefslogtreecommitdiff
path: root/lib/pleroma/web/activity_pub/activity_pub_controller.ex
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pleroma/web/activity_pub/activity_pub_controller.ex')
-rw-r--r--lib/pleroma/web/activity_pub/activity_pub_controller.ex49
1 files changed, 25 insertions, 24 deletions
diff --git a/lib/pleroma/web/activity_pub/activity_pub_controller.ex b/lib/pleroma/web/activity_pub/activity_pub_controller.ex
index 2bb5bd15b..a64199cd6 100644
--- a/lib/pleroma/web/activity_pub/activity_pub_controller.ex
+++ b/lib/pleroma/web/activity_pub/activity_pub_controller.ex
@@ -18,6 +18,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
alias Pleroma.Web.ActivityPub.UserView
alias Pleroma.Web.ActivityPub.Utils
alias Pleroma.Web.ActivityPub.Visibility
+ alias Pleroma.Web.ControllerHelper
alias Pleroma.Web.Federator
require Logger
@@ -200,31 +201,29 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
end
end
- def outbox(conn, %{"nickname" => nickname, "page" => page?} = params)
+ def outbox(
+ %{assigns: %{user: for_user}} = conn,
+ %{"nickname" => nickname, "page" => page?} = params
+ )
when page? in [true, "true"] do
with %User{} = user <- User.get_cached_by_nickname(nickname),
{:ok, user} <- User.ensure_keys_present(user) do
- activities =
- if params["max_id"] do
- ActivityPub.fetch_user_activities(user, nil, %{
- "max_id" => params["max_id"],
- # This is a hack because postgres generates inefficient queries when filtering by
- # 'Answer', poll votes will be hidden by the visibility filter in this case anyway
- "include_poll_votes" => true,
- "limit" => 10
- })
- else
- ActivityPub.fetch_user_activities(user, nil, %{
- "limit" => 10,
- "include_poll_votes" => true
- })
- end
+ # "include_poll_votes" is a hack because postgres generates inefficient
+ # queries when filtering by 'Answer', poll votes will be hidden by the
+ # visibility filter in this case anyway
+ params =
+ params
+ |> Map.drop(["nickname", "page"])
+ |> Map.put("include_poll_votes", true)
+
+ activities = ActivityPub.fetch_user_activities(user, for_user, params)
conn
|> put_resp_content_type("application/activity+json")
|> put_view(UserView)
|> render("activity_collection_page.json", %{
activities: activities,
+ pagination: ControllerHelper.get_pagination_fields(conn, activities),
iri: "#{user.ap_id}/outbox"
})
end
@@ -318,21 +317,23 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
%{"nickname" => nickname, "page" => page?} = params
)
when page? in [true, "true"] do
+ params =
+ params
+ |> Map.drop(["nickname", "page"])
+ |> Map.put("blocking_user", user)
+ |> Map.put("user", user)
+
activities =
- if params["max_id"] do
- ActivityPub.fetch_activities([user.ap_id | User.following(user)], %{
- "max_id" => params["max_id"],
- "limit" => 10
- })
- else
- ActivityPub.fetch_activities([user.ap_id | User.following(user)], %{"limit" => 10})
- end
+ [user.ap_id | User.following(user)]
+ |> ActivityPub.fetch_activities(params)
+ |> Enum.reverse()
conn
|> put_resp_content_type("application/activity+json")
|> put_view(UserView)
|> render("activity_collection_page.json", %{
activities: activities,
+ pagination: ControllerHelper.get_pagination_fields(conn, activities),
iri: "#{user.ap_id}/inbox"
})
end