+ def handle_incoming(%{"type" => type} = data, _options) when type in ~w(Add Remove) do
+ with {:ok, %User{} = user} <- ObjectValidator.fetch_actor(data),
+ # 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
+ end
+ end
+