activitypub: implement activity flattening

This commit is contained in:
William Pitcock 2018-11-25 21:44:03 +00:00
parent 57d90e7afe
commit d13d953385
2 changed files with 9 additions and 5 deletions

View File

@ -57,7 +57,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
map <- lazy_put_activity_defaults(map), map <- lazy_put_activity_defaults(map),
:ok <- check_actor_is_active(map["actor"]), :ok <- check_actor_is_active(map["actor"]),
{:ok, map} <- MRF.filter(map), {:ok, map} <- MRF.filter(map),
:ok <- insert_full_object(map) do {:ok, map} <- insert_full_object(map) do
{recipients, _, _} = get_recipients(map) {recipients, _, _} = get_recipients(map)
{:ok, activity} = {:ok, activity} =

View File

@ -180,14 +180,18 @@ defmodule Pleroma.Web.ActivityPub.Utils do
@doc """ @doc """
Inserts a full object if it is contained in an activity. Inserts a full object if it is contained in an activity.
""" """
def insert_full_object(%{"object" => %{"type" => type} = object_data}) def insert_full_object(%{"object" => %{"type" => type} = object_data} = map)
when is_map(object_data) and type in @supported_object_types do when is_map(object_data) and type in @supported_object_types do
with {:ok, _} <- Object.create(object_data) do with {:ok, object} <- Object.create(object_data) do
:ok map =
map
|> Map.put("object", object.data["id"])
{:ok, map}
end end
end end
def insert_full_object(_), do: :ok def insert_full_object(map), do: {:ok, map}
def update_object_in_activities(%{data: %{"id" => id}} = object) do def update_object_in_activities(%{data: %{"id" => id}} = object) do
# TODO # TODO