mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-22 16:16:34 +00:00
Move the check to the inbox
This commit is contained in:
parent
4bc6f334f4
commit
1c394dd18c
2 changed files with 26 additions and 21 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue