activitypub: splice in the child object if we have one

This commit is contained in:
William Pitcock 2019-03-23 00:40:08 +00:00
parent a6973a668e
commit e4307cadc8
2 changed files with 12 additions and 4 deletions

View file

@ -95,7 +95,7 @@ def insert(map, local \\ true) when is_map(map) do
:ok <- check_actor_is_active(map["actor"]),
{_, true} <- {:remote_limit_error, check_remote_limit(map)},
{:ok, map} <- MRF.filter(map),
:ok <- insert_full_object(map) do
{:ok, object} <- insert_full_object(map) do
{recipients, _, _} = get_recipients(map)
{:ok, activity} =
@ -106,6 +106,14 @@ def insert(map, local \\ true) when is_map(map) do
recipients: recipients
})
# Splice in the child object if we have one.
activity =
if !is_nil(object) do
Map.put(activity, :object, object)
else
activity
end
Task.start(fn ->
Pleroma.Web.RichMedia.Helpers.fetch_data_for_activity(activity)
end)

View file

@ -209,12 +209,12 @@ def lazy_put_object_defaults(map, activity \\ %{}) do
"""
def insert_full_object(%{"object" => %{"type" => type} = object_data})
when is_map(object_data) and type in @supported_object_types do
with {:ok, _} <- Object.create(object_data) do
:ok
with {:ok, object} <- Object.create(object_data) do
{:ok, object}
end
end
def insert_full_object(_), do: :ok
def insert_full_object(_), do: {:ok, nil}
def update_object_in_activities(%{data: %{"id" => id}} = object) do
# TODO