fix remote hashtags
authorFloatingGhost <hannah@coffee-and-dreams.uk>
Thu, 16 Dec 2021 15:09:36 +0000 (15:09 +0000)
committerFloatingGhost <hannah@coffee-and-dreams.uk>
Thu, 16 Dec 2021 15:20:34 +0000 (15:20 +0000)
lib/pleroma/elasticsearch/store.ex
lib/pleroma/hashtag.ex

index 4789aebe016b78f88f7dcffd328c305af53fc69c..aa5e2b1040689e29944ac93255d0080cf1ba9d3e 100644 (file)
@@ -54,12 +54,6 @@ defmodule Pleroma.Elasticsearch do
         DocumentMappings.Activity.id(activity),
         DocumentMappings.Activity.encode(activity)
       )
-
-    {:ok, _} =
-      bulk_post(
-        activity.object.hashtags,
-        :hashtags
-      )
   end
 
   def put(%User{} = user) do
@@ -101,6 +95,12 @@ defmodule Pleroma.Elasticsearch do
       )
   end
 
+  def maybe_bulk_post(data, type) do
+    if enabled?() do
+      bulk_post(data, type)
+    end
+  end
+
   def bulk_post(data, :users) do
     d =
       data
index 53e2e9c897d564dd788306a72fa640ff75cbdce8..1eae4d1e71166ee87adddb0d16d3fb3e87ca836a 100644 (file)
@@ -61,6 +61,7 @@ defmodule Pleroma.Hashtag do
                {:ok, Repo.all(from(ht in Hashtag, where: ht.name in ^names))}
              end)
              |> Repo.transaction() do
+        Pleroma.Elasticsearch.bulk_post(hashtags, :hashtags)
         {:ok, hashtags}
       else
         {:error, _name, value, _changes_so_far} -> {:error, value}