Don't try removing deleted users and such from index as posts
authorEkaterina Vaartis <vaartis@kotobank.ch>
Sat, 22 Jan 2022 13:52:06 +0000 (16:52 +0300)
committerFloatingGhost <hannah@coffee-and-dreams.uk>
Wed, 29 Jun 2022 19:49:45 +0000 (20:49 +0100)
lib/pleroma/search.ex
lib/pleroma/web/activity_pub/side_effects.ex

index af858fc46965198f67fafed29fc59e24f2b2c1d0..3b266e59bbb90e8251302ab7d74febde6c541546 100644 (file)
@@ -1,12 +1,12 @@
 defmodule Pleroma.Search do
   alias Pleroma.Workers.SearchIndexingWorker
 
-  def add_to_index(activity) do
-    SearchIndexingWorker.enqueue("add_to_index", %{"activity" => activity.id})
+  def add_to_index(%Pleroma.Activity{id: activity_id}) do
+    SearchIndexingWorker.enqueue("add_to_index", %{"activity" => activity_id})
   end
 
-  def remove_from_index(object) do
-    SearchIndexingWorker.enqueue("remove_from_index", %{"object" => object.id})
+  def remove_from_index(%Pleroma.Object{id: object_id}) do
+    SearchIndexingWorker.enqueue("remove_from_index", %{"object" => object_id})
   end
 
   def search(query, options) do
index 097afa30ec9cce179a0f98d29fe787293e488400..517dd0a4fa5881996d043f4147fde237d91b608b 100644 (file)
@@ -325,7 +325,10 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
     if result == :ok do
       Notification.create_notifications(object)
 
-      Pleroma.Search.remove_from_index(deleted_object)
+      # Only remove from index when deleting actual objects, not users or anything else
+      with %Pleroma.Object{} <- deleted_object do
+        Pleroma.Search.remove_from_index(deleted_object)
+      end
 
       {:ok, object, meta}
     else