Do not normalize objects in stream_out unless the activity type is
authorrinpatch <rinpatch@sdf.org>
Tue, 30 Apr 2019 17:21:28 +0000 (20:21 +0300)
committerrinpatch <rinpatch@sdf.org>
Tue, 30 Apr 2019 17:21:28 +0000 (20:21 +0300)
Create

Saves quite a bit of time with delete activities because they would
always query the db

lib/pleroma/web/activity_pub/activity_pub.ex

index 604ffae7b4e50df0d525e94c0f7dbda0711d217c..483a2153fb31db107b200b6a18215c151d50ab6f 100644 (file)
@@ -168,7 +168,6 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
     public = "https://www.w3.org/ns/activitystreams#Public"
 
     if activity.data["type"] in ["Create", "Announce", "Delete"] do
-      object = Object.normalize(activity)
       Pleroma.Web.Streamer.stream("user", activity)
       Pleroma.Web.Streamer.stream("list", activity)
 
@@ -180,6 +179,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
         end
 
         if activity.data["type"] in ["Create"] do
+          object = Object.normalize(activity)
+
           object.data
           |> Map.get("tag", [])
           |> Enum.filter(fn tag -> is_bitstring(tag) end)