Use content instead of source and scrub it
This commit is contained in:
parent
9beaebd97e
commit
00c48a33ac
@ -37,7 +37,7 @@ defmodule Mix.Tasks.Pleroma.Search.Meilisearch do
|
||||
# Only index public posts which are notes and have some text
|
||||
where:
|
||||
fragment("data->>'type' = 'Note'") and
|
||||
fragment("LENGTH(data->>'source') > 0") and
|
||||
fragment("LENGTH(data->>'content') > 0") and
|
||||
fragment("data->'to' \\? ?", ^Pleroma.Constants.as_public()),
|
||||
order_by: [desc: fragment("data->'published'")]
|
||||
),
|
||||
@ -56,10 +56,11 @@ defmodule Mix.Tasks.Pleroma.Search.Meilisearch do
|
||||
data = object.data
|
||||
|
||||
{:ok, published, _} = DateTime.from_iso8601(data["published"])
|
||||
{:ok, content} = FastSanitize.strip_tags(data["content"])
|
||||
|
||||
%{
|
||||
id: object.id,
|
||||
source: data["source"],
|
||||
content: content,
|
||||
ap: data["id"],
|
||||
published: published |> DateTime.to_unix()
|
||||
}
|
||||
@ -87,11 +88,6 @@ defmodule Mix.Tasks.Pleroma.Search.Meilisearch do
|
||||
|
||||
endpoint = Pleroma.Config.get([Pleroma.Search.Meilisearch, :url])
|
||||
|
||||
{:ok, result} =
|
||||
Pleroma.HTTP.request(:delete, "#{endpoint}/indexes/objects/documents", "", [], [])
|
||||
|
||||
if not Map.has_key?(Jason.decode!(result.body), "updateId") do
|
||||
IO.puts("Failed to clear: #{result}")
|
||||
end
|
||||
{:ok, _} = Pleroma.HTTP.request(:delete, "#{endpoint}/indexes/objects", "", [], [])
|
||||
end
|
||||
end
|
||||
|
@ -56,7 +56,7 @@ defmodule Pleroma.Search.Meilisearch do
|
||||
Jason.encode!([
|
||||
%{
|
||||
id: object.id,
|
||||
source: data["source"],
|
||||
content: data["content"] |> Pleroma.HTML.filter_tags(),
|
||||
ap: data["id"],
|
||||
published: published |> DateTime.to_unix()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user