From 418212c71c71358557e3d72c64394b790bf60557 Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Thu, 16 Dec 2021 15:09:36 +0000 Subject: [PATCH] fix remote hashtags --- lib/pleroma/elasticsearch/store.ex | 12 ++++++------ lib/pleroma/hashtag.ex | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/pleroma/elasticsearch/store.ex b/lib/pleroma/elasticsearch/store.ex index 291fdf075..0860a5ee5 100644 --- a/lib/pleroma/elasticsearch/store.ex +++ b/lib/pleroma/elasticsearch/store.ex @@ -54,12 +54,6 @@ def put(%Activity{} = activity) 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 @@ def bulk_post(data, :activities) 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 diff --git a/lib/pleroma/hashtag.ex b/lib/pleroma/hashtag.ex index 53e2e9c89..1eae4d1e7 100644 --- a/lib/pleroma/hashtag.ex +++ b/lib/pleroma/hashtag.ex @@ -61,6 +61,7 @@ def get_or_create_by_names(names) when is_list(names) 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}