mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-22 16:16:34 +00:00
Move user active check into Federator.perform/1
This commit is contained in:
parent
e498d252e4
commit
1821ef4f15
3 changed files with 10 additions and 12 deletions
|
@ -102,7 +102,8 @@ defmodule Pleroma.Web.Federator do
|
||||||
|
|
||||||
# NOTE: we use the actor ID to do the containment, this is fine because an
|
# NOTE: we use the actor ID to do the containment, this is fine because an
|
||||||
# actor shouldn't be acting on objects outside their own AP server.
|
# actor shouldn't be acting on objects outside their own AP server.
|
||||||
with {_, {:ok, _user}} <- {:actor, User.get_or_fetch_by_ap_id(actor)},
|
with {_, {:ok, user}} <- {:actor, User.get_or_fetch_by_ap_id(actor)},
|
||||||
|
{:user_active, true} <- {:user_active, match?(true, user.is_active)},
|
||||||
nil <- Activity.normalize(params["id"]),
|
nil <- Activity.normalize(params["id"]),
|
||||||
{_, :ok} <-
|
{_, :ok} <-
|
||||||
{:correct_origin?, Containment.contain_origin_from_id(actor, params)},
|
{:correct_origin?, Containment.contain_origin_from_id(actor, params)},
|
||||||
|
|
|
@ -33,8 +33,7 @@ defmodule Pleroma.Workers.ReceiverWorker do
|
||||||
query_string: query_string
|
query_string: query_string
|
||||||
}
|
}
|
||||||
|
|
||||||
with {:ok, %User{} = actor} <- User.get_or_fetch_by_ap_id(conn_data.params["actor"]),
|
with {:ok, %User{}} <- User.get_or_fetch_by_ap_id(conn_data.params["actor"]),
|
||||||
{:user_active, true} <- {:user_active, match?(true, actor.is_active)},
|
|
||||||
{:ok, _public_key} <- Signature.refetch_public_key(conn_data),
|
{:ok, _public_key} <- Signature.refetch_public_key(conn_data),
|
||||||
{:signature, true} <- {:signature, Signature.validate_signature(conn_data)},
|
{:signature, true} <- {:signature, Signature.validate_signature(conn_data)},
|
||||||
{:ok, res} <- Federator.perform(:incoming_ap_doc, params) do
|
{:ok, res} <- Federator.perform(:incoming_ap_doc, params) do
|
||||||
|
@ -65,7 +64,7 @@ defmodule Pleroma.Workers.ReceiverWorker do
|
||||||
{:error, :not_found} = reason -> {:cancel, reason}
|
{:error, :not_found} = reason -> {:cancel, reason}
|
||||||
{:error, :forbidden} = reason -> {:cancel, reason}
|
{:error, :forbidden} = reason -> {:cancel, reason}
|
||||||
# Inactive user
|
# Inactive user
|
||||||
{:user_active, false} = reason -> {:cancel, reason}
|
{:error, {:user_active, false} = reason} -> {:cancel, reason}
|
||||||
# Validator will error and return a changeset error
|
# Validator will error and return a changeset error
|
||||||
# e.g., duplicate activities or if the object was deleted
|
# e.g., duplicate activities or if the object was deleted
|
||||||
{:error, {:validate, {:error, _changeset} = reason}} -> {:cancel, reason}
|
{:error, {:validate, {:error, _changeset} = reason}} -> {:cancel, reason}
|
||||||
|
|
|
@ -138,15 +138,13 @@ defmodule Pleroma.Workers.ReceiverWorkerTest do
|
||||||
{:ok, %User{}} = User.set_activation(user, false)
|
{:ok, %User{}} = User.set_activation(user, false)
|
||||||
|
|
||||||
{:ok, oban_job} =
|
{:ok, oban_job} =
|
||||||
ReceiverWorker.new(%{
|
Federator.incoming_ap_doc(%{
|
||||||
"op" => "incoming_ap_doc",
|
method: "POST",
|
||||||
"method" => "POST",
|
req_headers: [],
|
||||||
"req_headers" => [],
|
request_path: "/inbox",
|
||||||
"request_path" => "/inbox",
|
params: params,
|
||||||
"params" => params,
|
query_string: ""
|
||||||
"query_string" => ""
|
|
||||||
})
|
})
|
||||||
|> Oban.insert()
|
|
||||||
|
|
||||||
assert {:cancel, {:user_active, false}} = ReceiverWorker.perform(oban_job)
|
assert {:cancel, {:user_active, false}} = ReceiverWorker.perform(oban_job)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue