Merge branch 'develop' into feature/database-compaction
[akkoma] / lib / pleroma / web / twitter_api / twitter_api.ex
index d6ce0a7c609878833fb039c29a094aa40f1b7fe4..8e44dbeb88ca5a47a217f4452f5d9611a9f3f2f6 100644 (file)
@@ -266,6 +266,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
 
   defp parse_int(_, default), do: default
 
+  # TODO: unify the search query with MastoAPI one and do only pagination here
   def search(_user, %{"q" => query} = params) do
     limit = parse_int(params["rpp"], 20)
     page = parse_int(params["page"], 1)
@@ -273,13 +274,13 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI 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: ^limit,