defmodule Pleroma.Elasticsearch do
alias Pleroma.Activity
alias Pleroma.User
+ alias Pleroma.Object
alias Pleroma.Elasticsearch.DocumentMappings
alias Pleroma.Config
require Logger
{:ok, :skipped}
end
+ def maybe_bulk_post(data, type) do
+ if enabled?() do
+ bulk_post(data, type)
+ end
+ end
+
def put(%Activity{} = activity) do
{:ok, _} =
Elastix.Document.index(
DocumentMappings.Activity.id(activity),
DocumentMappings.Activity.encode(activity)
)
+
+ activity
+ |> Map.get(:object)
+ |> Object.hashtags()
+ |> Enum.map(fn x -> %{id: x, name: x, timestamp: DateTime.to_iso8601(DateTime.utc_now())} end)
+ |> bulk_post(:hashtags)
end
def put(%User{} = user) 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 =
)
end
- def bulk_post([] = data, :hashtags) do
+ def bulk_post(data, :hashtags) when is_list(data) do
d =
data
|> Enum.map(fn d ->