Change the order of preloading when fetching activities for context
authorrinpatch <rinpatch@sdf.org>
Thu, 23 May 2019 11:03:16 +0000 (14:03 +0300)
committerrinpatch <rinpatch@sdf.org>
Thu, 23 May 2019 11:03:16 +0000 (14:03 +0300)
lib/pleroma/web/activity_pub/activity_pub.ex

index db5a4a7ee0a7b921d4b019f22de23322ec782a54..b06200cb5b6f2ca73babcf7830ad27c85a42f9da 100644 (file)
@@ -492,7 +492,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
       if opts["user"], do: [opts["user"].ap_id | opts["user"].following] ++ public, else: public
 
     from(activity in Activity)
-    |> Activity.with_preloaded_object()
+    |> maybe_preload_objects(opts)
     |> exclude_poll_votes(opts)
     |> restrict_blocked(opts)
     |> restrict_recipients(recipients, opts["user"])
@@ -513,7 +513,6 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
   def fetch_activities_for_context(context, opts \\ %{}) do
     context
     |> fetch_activities_for_context_query(opts)
-    |> Activity.with_preloaded_object()
     |> Repo.all()
   end
 
@@ -521,7 +520,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
           Pleroma.FlakeId.t() | nil
   def fetch_latest_activity_id_for_context(context, opts \\ %{}) do
     context
-    |> fetch_activities_for_context_query(opts)
+    |> fetch_activities_for_context_query(Map.merge(%{"skip_preload" => true}, opts))
     |> limit(1)
     |> select([a], a.id)
     |> Repo.one()