activitypub: implement activity flattening
authorWilliam Pitcock <nenolod@dereferenced.org>
Sun, 25 Nov 2018 21:44:03 +0000 (21:44 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Tue, 4 Dec 2018 04:52:09 +0000 (04:52 +0000)
lib/pleroma/web/activity_pub/activity_pub.ex
lib/pleroma/web/activity_pub/utils.ex

index b11d3221f14f7c9d44edc39b707451f486452c3b..dcf670afb573ea5ded751f6672594bf88e1cd6ee 100644 (file)
@@ -57,7 +57,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
          map <- lazy_put_activity_defaults(map),
          :ok <- check_actor_is_active(map["actor"]),
          {:ok, map} <- MRF.filter(map),
-         :ok <- insert_full_object(map) do
+         {:ok, map} <- insert_full_object(map) do
       {recipients, _, _} = get_recipients(map)
 
       {:ok, activity} =
index 5491489896204a04a50e91a9fb10e201e0aaa415..bc5b98f1a0594edbd4b5c6bfb3ba4d43d3e6c97f 100644 (file)
@@ -180,14 +180,18 @@ defmodule Pleroma.Web.ActivityPub.Utils do
   @doc """
   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
-    with {:ok, _} <- Object.create(object_data) do
-      :ok
+    with {:ok, object} <- Object.create(object_data) do
+      map =
+        map
+        |> Map.put("object", object.data["id"])
+
+      {:ok, map}
     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
     # TODO