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:09:36 +0000 (15:09 +0000)
lib/pleroma/elasticsearch/store.ex
lib/pleroma/hashtag.ex

index 291fdf0752aa14a8f9bab09380ab625014816ba5..0860a5ee5ff601b328042e4e3967b5e483872933 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}