Fix object search depending on embeded object
authorrinpatch <rinpatch@sdf.org>
Thu, 18 Apr 2019 06:28:20 +0000 (09:28 +0300)
committerrinpatch <rinpatch@sdf.org>
Thu, 18 Apr 2019 06:28:20 +0000 (09:28 +0300)
lib/pleroma/web/activity_pub/visibility.ex
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
test/user_test.exs

index 3da709b3d5c242a5b2a5fb82fb7cbecd3e17fec2..6dee61dd61b02bf9dc337d86becb7faa807b711f 100644 (file)
@@ -41,7 +41,9 @@ defmodule Pleroma.Web.ActivityPub.Visibility do
   # guard
   def entire_thread_visible_for_user?(nil, _user), do: false
 
-  # XXX: Probably even more inefficient than the previous implementation, intended to be a placeholder untill https://git.pleroma.social/pleroma/pleroma/merge_requests/971 is in develop
+  # XXX: Probably even more inefficient than the previous implementation intended to be a placeholder untill https://git.pleroma.social/pleroma/pleroma/merge_requests/971 is in develop
+  # credo:disable-for-previous-line Credo.Check.Readability.MaxLineLength
+
   def entire_thread_visible_for_user?(
         %Activity{} = tail,
         # %Activity{data: %{"object" => %{"inReplyTo" => parent_id}}} = tail,
index 4cec26c9b1b31d9b5723e22b8cb08b4194d91ef2..3916d7c41da3d56443bf57bae630ec9525b1e001 100644 (file)
@@ -1012,13 +1012,13 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
 
     q =
       from(
-        a in Activity,
+        [a, o] in Activity.with_preloaded_object(Activity),
         where: fragment("?->>'type' = 'Create'", a.data),
         where: "https://www.w3.org/ns/activitystreams#Public" in a.recipients,
         where:
           fragment(
-            "to_tsvector('english', ?->'object'->>'content') @@ plainto_tsquery('english', ?)",
-            a.data,
+            "to_tsvector('english', ?->>'content') @@ plainto_tsquery('english', ?)",
+            o.data,
             ^query
           ),
         limit: 20,
index 6ce5b9cf5ad8ff98504928e195362124cfbabb8a..eee6881eb7f49cf145df5f90a78b4d8307e22777 100644 (file)
@@ -4,8 +4,8 @@
 
 defmodule Pleroma.UserTest do
   alias Pleroma.Activity
-  alias Pleroma.Object
   alias Pleroma.Builders.UserBuilder
+  alias Pleroma.Object
   alias Pleroma.Repo
   alias Pleroma.User
   alias Pleroma.Web.CommonAPI