commit: 1c394dd18c5d61dc716a9b9cda981a359de32456
parent 4bc6f334f49c27e1f466052fee6fa2f3d5d2ee74
Author: Mark Felder <feld@feld.me>
Date: Fri, 23 Aug 2024 14:24:04 -0400
Move the check to the inbox
Diffstat:
2 files changed, 26 insertions(+), 21 deletions(-)
diff --git a/lib/pleroma/web/activity_pub/activity_pub_controller.ex b/lib/pleroma/web/activity_pub/activity_pub_controller.ex
@@ -294,13 +294,19 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
end
def inbox(%{assigns: %{valid_signature: false}} = conn, params) do
- Federator.incoming_ap_doc(%{
- method: conn.method,
- req_headers: conn.req_headers,
- request_path: conn.request_path,
- params: params,
- query_string: conn.query_string
- })
+ case unknown_delete?(params) do
+ true ->
+ :ok
+
+ false ->
+ Federator.incoming_ap_doc(%{
+ method: conn.method,
+ req_headers: conn.req_headers,
+ request_path: conn.request_path,
+ params: params,
+ query_string: conn.query_string
+ })
+ end
json(conn, "ok")
end
@@ -558,4 +564,16 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
|> json(UserView.render("featured.json", %{user: user}))
end
end
+
+ defp unknown_delete?(%{
+ "type" => "Delete",
+ "actor" => actor
+ }) do
+ case User.get_cached_by_ap_id(actor) do
+ %User{} -> false
+ _ -> true
+ end
+ end
+
+ defp unknown_delete?(_), do: false
end
diff --git a/lib/pleroma/workers/receiver_worker.ex b/lib/pleroma/workers/receiver_worker.ex
@@ -33,8 +33,7 @@ defmodule Pleroma.Workers.ReceiverWorker do
query_string: query_string
}
- with {_, false} <- {:unknown_delete, unknown_delete?(params)},
- {:ok, %User{} = _actor} <- User.get_or_fetch_by_ap_id(conn_data.params["actor"]),
+ with {:ok, %User{} = _actor} <- User.get_or_fetch_by_ap_id(conn_data.params["actor"]),
{:ok, _public_key} <- Signature.refetch_public_key(conn_data),
{:signature, true} <- {:signature, Signature.validate_signature(conn_data)},
{:ok, res} <- Federator.perform(:incoming_ap_doc, params) do
@@ -73,16 +72,4 @@ defmodule Pleroma.Workers.ReceiverWorker do
e -> {:error, e}
end
end
-
- defp unknown_delete?(%{
- "type" => "Delete",
- "actor" => actor
- }) do
- case User.get_cached_by_ap_id(actor) do
- %User{} -> false
- _ -> true
- end
- end
-
- defp unknown_delete?(_), do: false
end