Store status data inside flag activity
authorMaxim Filippov <colixer@gmail.com>
Tue, 15 Oct 2019 14:52:41 +0000 (16:52 +0200)
committerMaxim Filippov <colixer@gmail.com>
Tue, 15 Oct 2019 14:52:41 +0000 (16:52 +0200)
lib/pleroma/web/activity_pub/utils.ex

index 4ef479f96de5a0b81ab7dbb49bdabe238a1498d3..57982eb4adcf5ffa04c8bcb2cc17c8e66240e441 100644 (file)
@@ -609,9 +609,33 @@ defmodule Pleroma.Web.ActivityPub.Utils do
   defp build_flag_object(%{account: account, statuses: statuses} = _) do
     [account.ap_id] ++
       Enum.map(statuses || [], fn
-        %Activity{} = act -> act.data["id"]
-        act when is_map(act) -> act["id"]
-        act when is_binary(act) -> act
+        %Activity{} = act ->
+          obj = Object.get_by_ap_id(act.data["object"])
+
+          %{
+            "type" => "Note",
+            "id" => act.data["id"],
+            "content" => obj.data["content"]
+          }
+
+        act when is_map(act) ->
+          obj = Object.get_by_ap_id(act["object"])
+
+          %{
+            "type" => "Note",
+            "id" => act["id"],
+            "content" => obj.data["content"]
+          }
+
+        act
+        when is_binary(act) ->
+          activity = Activity.get_by_ap_id_with_object(act)
+
+          %{
+            "type" => "Note",
+            "id" => activity.data["id"],
+            "content" => activity.data["object"]["content"]
+          }
       end)
   end