projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Bugfix: Reuse Controller.Helper pagination for APC2S
[akkoma]
/
lib
/
pleroma
/
web
/
activity_pub
/
activity_pub_controller.ex
diff --git
a/lib/pleroma/web/activity_pub/activity_pub_controller.ex
b/lib/pleroma/web/activity_pub/activity_pub_controller.ex
index 504eed4f40f7f9a23d43fc925e6d569f90dd218b..b624d4255c0f631833e951bd8ddb1c15ad00080b 100644
(file)
--- a/
lib/pleroma/web/activity_pub/activity_pub_controller.ex
+++ b/
lib/pleroma/web/activity_pub/activity_pub_controller.ex
@@
-21,6
+21,8
@@
defmodule Pleroma.Web.ActivityPub.ActivityPubController do
alias Pleroma.Web.ActivityPub.UserView
alias Pleroma.Web.ActivityPub.Utils
alias Pleroma.Web.ActivityPub.Visibility
alias Pleroma.Web.ActivityPub.UserView
alias Pleroma.Web.ActivityPub.Utils
alias Pleroma.Web.ActivityPub.Visibility
+ alias Pleroma.Web.ControllerHelper
+ alias Pleroma.Web.Endpoint
alias Pleroma.Web.FederatingPlug
alias Pleroma.Web.Federator
alias Pleroma.Web.FederatingPlug
alias Pleroma.Web.Federator
@@
-34,7
+36,7
@@
defmodule Pleroma.Web.ActivityPub.ActivityPubController do
plug(
EnsureAuthenticatedPlug,
plug(
EnsureAuthenticatedPlug,
- [unless_func: &FederatingPlug.federating?/
0
] when action not in @federating_only_actions
+ [unless_func: &FederatingPlug.federating?/
1
] when action not in @federating_only_actions
)
# Note: :following and :followers must be served even without authentication (as via :api)
)
# Note: :following and :followers must be served even without authentication (as via :api)
@@
-75,8
+77,8
@@
defmodule Pleroma.Web.ActivityPub.ActivityPubController do
end
end
end
end
- def object(conn,
%{"uuid" => uuid}
) do
- with ap_id <-
o_status_url(conn, :object, uuid)
,
+ def object(conn,
_
) do
+ with ap_id <-
Endpoint.url() <> conn.request_path
,
%Object{} = object <- Object.get_cached_by_ap_id(ap_id),
{_, true} <- {:public?, Visibility.is_public?(object)} do
conn
%Object{} = object <- Object.get_cached_by_ap_id(ap_id),
{_, true} <- {:public?, Visibility.is_public?(object)} do
conn
@@
-101,8
+103,8
@@
defmodule Pleroma.Web.ActivityPub.ActivityPubController do
conn
end
conn
end
- def activity(conn,
%{"uuid" => uuid}
) do
- with ap_id <-
o_status_url(conn, :activity, uuid)
,
+ def activity(conn,
_params
) do
+ with ap_id <-
Endpoint.url() <> conn.request_path
,
%Activity{} = activity <- Activity.normalize(ap_id),
{_, true} <- {:public?, Visibility.is_public?(activity)} do
conn
%Activity{} = activity <- Activity.normalize(ap_id),
{_, true} <- {:public?, Visibility.is_public?(activity)} do
conn
@@
-250,6
+252,7
@@
defmodule Pleroma.Web.ActivityPub.ActivityPubController do
|> put_view(UserView)
|> render("activity_collection_page.json", %{
activities: activities,
|> put_view(UserView)
|> render("activity_collection_page.json", %{
activities: activities,
+ pagination: ControllerHelper.get_pagination_fields(conn, activities, %{"limit" => "10"}),
iri: "#{user.ap_id}/outbox"
})
end
iri: "#{user.ap_id}/outbox"
})
end
@@
-367,6
+370,7
@@
defmodule Pleroma.Web.ActivityPub.ActivityPubController do
|> put_view(UserView)
|> render("activity_collection_page.json", %{
activities: activities,
|> put_view(UserView)
|> render("activity_collection_page.json", %{
activities: activities,
+ pagination: ControllerHelper.get_pagination_fields(conn, activities, %{"limit" => "10"}),
iri: "#{user.ap_id}/inbox"
})
end
iri: "#{user.ap_id}/inbox"
})
end
@@
-418,7
+422,8
@@
defmodule Pleroma.Web.ActivityPub.ActivityPubController do
defp handle_user_activity(%User{} = user, %{"type" => "Delete"} = params) do
with %Object{} = object <- Object.normalize(params["object"]),
true <- user.is_moderator || user.ap_id == object.data["actor"],
defp handle_user_activity(%User{} = user, %{"type" => "Delete"} = params) do
with %Object{} = object <- Object.normalize(params["object"]),
true <- user.is_moderator || user.ap_id == object.data["actor"],
- {:ok, delete} <- ActivityPub.delete(object) do
+ {:ok, delete_data, _} <- Builder.delete(user, object.data["id"]),
+ {:ok, delete, _} <- Pipeline.common_pipeline(delete_data, local: true) do
{:ok, delete}
else
_ -> {:error, dgettext("errors", "Can't delete object")}
{:ok, delete}
else
_ -> {:error, dgettext("errors", "Can't delete object")}