Verified Commit 71c95dfc authored by Haelwenn's avatar Haelwenn

Keep only pure-federation side-effects of user.ap_enabled

Only parts kept are:
- Do not push to non AP-enabled actors
- Upgrade actors to AP-enabled when receiving an Activity from them
parent 636b99c5
Pipeline #26026 failed with stages
in 3 minutes and 10 seconds
......@@ -704,12 +704,8 @@ def maybe_direct_follow(%User{} = follower, %User{local: true} = followed) do
follow(follower, followed)
def maybe_direct_follow(%User{} = follower, %User{} = followed) do
if not ap_enabled?(followed) do
follow(follower, followed)
{:ok, follower}
def maybe_direct_follow(%User{} = follower, _followed) do
{:ok, follower}
@doc "A mass follow for local users. Respects blocks in both directions but does not create activities."
......@@ -42,10 +42,6 @@ defmodule Pleroma.Web.ActivityPub.Utils do
def get_ap_id(%{"id" => id} = _), do: id
def get_ap_id(id), do: id
def normalize_params(params) do
Map.put(params, "actor", get_ap_id(params["actor"]))
@spec determine_explicit_mentions(map()) :: [any]
def determine_explicit_mentions(%{"tag" => tag}) when is_list(tag) do
Enum.flat_map(tag, fn
......@@ -8,7 +8,6 @@ defmodule Pleroma.Web.Federator do
alias Pleroma.User
alias Pleroma.Web.ActivityPub.ActivityPub
alias Pleroma.Web.ActivityPub.Transmogrifier
alias Pleroma.Web.ActivityPub.Utils
alias Pleroma.Web.Federator.Publisher
alias Pleroma.Workers.PublisherWorker
alias Pleroma.Workers.ReceiverWorker
......@@ -66,11 +65,11 @@ def perform(:publish, activity) do
def perform(:incoming_ap_doc, params) do
Logger.debug("Handling incoming AP activity")
params = Utils.normalize_params(params)
actor = Containment.get_actor(params)
# 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.
with {:ok, _user} <- ap_enabled_actor(params["actor"]),
with {_, {:ok, _user}} <- {:get_user, User.get_or_fetch_by_ap_id(actor)},
nil <- Activity.normalize(params["id"]),
{_, :ok} <-
{:correct_origin?, Containment.contain_origin_from_id(params["actor"], params)},
......@@ -92,14 +91,4 @@ def perform(:incoming_ap_doc, params) do
{:error, e}
def ap_enabled_actor(id) do
user = User.get_cached_by_ap_id(id)
if User.ap_enabled?(user) do
{:ok, user}
......@@ -8,7 +8,6 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.FollowHandlingTest do
alias Pleroma.Repo
alias Pleroma.User
alias Pleroma.Web.ActivityPub.Transmogrifier
alias Pleroma.Web.ActivityPub.Utils
import Pleroma.Factory
import Ecto.Query
......@@ -151,7 +150,6 @@ test "it works for incoming follow requests from hubzilla" do!("test/fixtures/hubzilla-follow-activity.json")
|> Poison.decode!()
|> Map.put("object", user.ap_id)
|> Utils.normalize_params()
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment