mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2025-04-24 13:57:23 -04:00
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
This commit is contained in:
parent
636b99c552
commit
71c95dfc1c
4 changed files with 4 additions and 25 deletions
|
@ -704,12 +704,8 @@ defmodule Pleroma.User do
|
|||
follow(follower, followed)
|
||||
end
|
||||
|
||||
def maybe_direct_follow(%User{} = follower, %User{} = followed) do
|
||||
if not ap_enabled?(followed) do
|
||||
follow(follower, followed)
|
||||
else
|
||||
{:ok, follower}
|
||||
end
|
||||
def maybe_direct_follow(%User{} = follower, _followed) do
|
||||
{:ok, follower}
|
||||
end
|
||||
|
||||
@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"]))
|
||||
end
|
||||
|
||||
@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 @@ defmodule Pleroma.Web.Federator 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 @@ defmodule Pleroma.Web.Federator do
|
|||
{:error, e}
|
||||
end
|
||||
end
|
||||
|
||||
def ap_enabled_actor(id) do
|
||||
user = User.get_cached_by_ap_id(id)
|
||||
|
||||
if User.ap_enabled?(user) do
|
||||
{:ok, user}
|
||||
else
|
||||
ActivityPub.make_user_from_ap_id(id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.FollowHandlingTest do
|
|||
File.read!("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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue