X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Factivity_pub%2Fpipeline.ex;h=195596f94e3e4138cc286113b45c116c2032c5ac;hb=1926d0804ba6ade106a509c027af6bf56e6a8791;hp=36e325c373d1463c9ac21f7a51913bf440201617;hpb=1298a2ea2c63f14cc080eb549377c6a1274b1628;p=akkoma
diff --git a/lib/pleroma/web/activity_pub/pipeline.ex b/lib/pleroma/web/activity_pub/pipeline.ex
index 36e325c37..195596f94 100644
--- a/lib/pleroma/web/activity_pub/pipeline.ex
+++ b/lib/pleroma/web/activity_pub/pipeline.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.Pipeline do
@@ -11,14 +11,22 @@ defmodule Pleroma.Web.ActivityPub.Pipeline do
alias Pleroma.Web.ActivityPub.MRF
alias Pleroma.Web.ActivityPub.ObjectValidator
alias Pleroma.Web.ActivityPub.SideEffects
+ alias Pleroma.Web.ActivityPub.Visibility
alias Pleroma.Web.Federator
+ @side_effects Config.get([:pipeline, :side_effects], SideEffects)
+ @federator Config.get([:pipeline, :federator], Federator)
+ @object_validator Config.get([:pipeline, :object_validator], ObjectValidator)
+ @mrf Config.get([:pipeline, :mrf], MRF)
+ @activity_pub Config.get([:pipeline, :activity_pub], ActivityPub)
+ @config Config.get([:pipeline, :config], Config)
+
@spec common_pipeline(map(), keyword()) ::
{:ok, Activity.t() | Object.t(), keyword()} | {:error, any()}
def common_pipeline(object, meta) do
case Repo.transaction(fn -> do_common_pipeline(object, meta) end) do
{:ok, {:ok, activity, meta}} ->
- SideEffects.handle_after_transaction(meta)
+ @side_effects.handle_after_transaction(meta)
{:ok, activity, meta}
{:ok, value} ->
@@ -26,21 +34,25 @@ defmodule Pleroma.Web.ActivityPub.Pipeline do
{:error, e} ->
{:error, e}
+
+ {:reject, e} ->
+ {:reject, e}
end
end
def do_common_pipeline(object, meta) do
with {_, {:ok, validated_object, meta}} <-
- {:validate_object, ObjectValidator.validate(object, meta)},
- {_, {:ok, mrfd_object}} <- {:mrf_object, MRF.filter(validated_object)},
+ {:validate_object, @object_validator.validate(object, meta)},
+ {_, {:ok, mrfd_object, meta}} <-
+ {:mrf_object, @mrf.pipeline_filter(validated_object, meta)},
{_, {:ok, activity, meta}} <-
- {:persist_object, ActivityPub.persist(mrfd_object, meta)},
+ {:persist_object, @activity_pub.persist(mrfd_object, meta)},
{_, {:ok, activity, meta}} <-
- {:execute_side_effects, SideEffects.handle(activity, meta)},
+ {:execute_side_effects, @side_effects.handle(activity, meta)},
{_, {:ok, _}} <- {:federation, maybe_federate(activity, meta)} do
{:ok, activity, meta}
else
- {:mrf_object, {:reject, _}} -> {:ok, nil, meta}
+ {:mrf_object, {:reject, message, _}} -> {:reject, message}
e -> {:error, e}
end
end
@@ -49,9 +61,9 @@ defmodule Pleroma.Web.ActivityPub.Pipeline do
defp maybe_federate(%Activity{} = activity, meta) do
with {:ok, local} <- Keyword.fetch(meta, :local) do
- do_not_federate = meta[:do_not_federate] || !Config.get([:instance, :federating])
+ do_not_federate = meta[:do_not_federate] || !@config.get([:instance, :federating])
- if !do_not_federate && local do
+ if !do_not_federate and local and not Visibility.is_local_public?(activity) do
activity =
if object = Keyword.get(meta, :object_data) do
%{activity | data: Map.put(activity.data, "object", object)}
@@ -59,7 +71,7 @@ defmodule Pleroma.Web.ActivityPub.Pipeline do
activity
end
- Federator.publish(activity)
+ @federator.publish(activity)
{:ok, :federated}
else
{:ok, :not_federated}