Rename search.ex to database_search.ex and add search/2
authorEkaterina Vaartis <vaartis@kotobank.ch>
Tue, 16 Nov 2021 18:54:26 +0000 (21:54 +0300)
committerFloatingGhost <hannah@coffee-and-dreams.uk>
Wed, 29 Jun 2022 19:49:00 +0000 (20:49 +0100)
lib/pleroma/search/database_search.ex [moved from lib/pleroma/search.ex with 68% similarity]
lib/pleroma/web/activity_pub/activity_pub.ex
lib/pleroma/web/activity_pub/side_effects.ex
lib/pleroma/web/mastodon_api/controllers/search_controller.ex

similarity index 68%
rename from lib/pleroma/search.ex
rename to lib/pleroma/search/database_search.ex
index e363abf1946763f7e3b2e88ac52575259f3c9bd0..be0e19be0675d60959b5725287f034f083775e06 100644 (file)
@@ -1,4 +1,4 @@
-defmodule Pleroma.Search do
+defmodule Pleroma.Search.DatabaseSearch do
   def add_to_index(activity) do
     search_module = Pleroma.Config.get([Pleroma.Search, :module])
 
@@ -15,4 +15,10 @@ defmodule Pleroma.Search do
       Task.start(fn -> search_module.remove_from_index(object) end)
     end)
   end
+
+  def search(query, options) do
+    search_module = Pleroma.Config.get([Pleroma.Search, :module], Pleroma.Activity)
+
+    search_module.search(options[:for_user], query, options)
+  end
 end
index e6548a8188a535d35cdfc29763bcce96cd63e94b..92b1be62c16ed2318d8c2431431447e6d222a2f1 100644 (file)
@@ -141,7 +141,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
       end)
 
       # Add local posts to search index
-      if local, do: Pleroma.Search.add_to_index(activity)
+      if local, do: Pleroma.Search.DatabaseSearch.add_to_index(activity)
 
       {:ok, activity}
     else
index 097afa30ec9cce179a0f98d29fe787293e488400..d08d6aa708594db5d81cbcd3b2b5013a4819450f 100644 (file)
@@ -223,7 +223,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
         Task.start(fn -> Pleroma.Web.RichMedia.Helpers.fetch_data_for_activity(activity) end)
       end)
 
-      Pleroma.Search.add_to_index(Map.put(activity, :object, object))
+      Pleroma.Search.DatabaseSearch.add_to_index(Map.put(activity, :object, object))
 
       meta =
         meta
@@ -325,7 +325,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
     if result == :ok do
       Notification.create_notifications(object)
 
-      Pleroma.Search.remove_from_index(deleted_object)
+      Pleroma.Search.DatabaseSearch.remove_from_index(deleted_object)
 
       {:ok, object, meta}
     else
index aaf52cdc597bb523dff377a5096a6bb2eac5a4f9..05fa4144d432ad0e99fbedc77ac233678a9adbcc 100644 (file)
@@ -76,9 +76,7 @@ defmodule Pleroma.Web.MastodonAPI.SearchController do
   end
 
   defp resource_search(_, "statuses", query, options) do
-    search_module = Pleroma.Config.get([Pleroma.Search, :module], Pleroma.Activity)
-
-    statuses = with_fallback(fn -> search_module.search(options[:for_user], query, options) end)
+    statuses = with_fallback(fn -> Pleroma.Search.DatabaseSearch.search(query, options) end)
 
     StatusView.render("index.json",
       activities: statuses,