expanding AddRemoveValidator
This commit is contained in:
parent
8857242c95
commit
2a520ba008
4 changed files with 27 additions and 26 deletions
|
|
@ -557,24 +557,12 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
|||
end
|
||||
|
||||
def handle_incoming(%{"type" => type} = data, _options) when type in ~w(Add Remove) do
|
||||
with {:ok, %User{} = user} <- ObjectValidator.fetch_actor(data),
|
||||
with :ok <- ObjectValidator.fetch_actor_and_object(data),
|
||||
{:ok, actor} <- Pleroma.User.get_or_fetch_by_ap_id(data["actor"]),
|
||||
# maybe locally user doesn't have featured_address
|
||||
{:ok, user} <- maybe_refetch_user(user),
|
||||
%Object{} <- Object.normalize(data["object"], fetch: true) do
|
||||
# Mastodon sends pin/unpin objects without id, to, cc fields
|
||||
data =
|
||||
data
|
||||
|> Map.put_new("id", Utils.generate_activity_id())
|
||||
|> Map.put_new("to", [Pleroma.Constants.as_public()])
|
||||
|> Map.put_new("cc", [user.follower_address])
|
||||
|
||||
case Pipeline.common_pipeline(data,
|
||||
local: false,
|
||||
featured_address: user.featured_address
|
||||
) do
|
||||
{:ok, activity, _meta} -> {:ok, activity}
|
||||
error -> error
|
||||
end
|
||||
{:ok, _} <- maybe_refetch_user(actor),
|
||||
{:ok, activity, _meta} <- Pipeline.common_pipeline(data, local: false) do
|
||||
{:ok, activity}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue