Insert text representation of hashtags into object["hashtags"]

Includes a new mix task: pleroma.database fill_old_hashtags
This commit is contained in:
Haelwenn (lanodan) Monnier 2020-07-31 16:46:35 +02:00
commit acb03d591b
No known key found for this signature in database
GPG key ID: D5B7A8E43C997DEE
22 changed files with 139 additions and 51 deletions

View file

@ -310,7 +310,16 @@ defmodule Pleroma.Web.CommonAPI.Utils do
"context" => draft.context,
"attachment" => draft.attachments,
"actor" => draft.user.ap_id,
"tag" => Keyword.values(draft.tags) |> Enum.uniq()
"tag" => Enum.filter(draft.tags, &is_map(&1)) |> Enum.uniq(),
"hashtags" =>
draft.tags
|> Enum.reduce([], fn
# Why so many formats
{:name, x}, acc -> if is_bitstring(x), do: [x | acc], else: acc
{"#" <> _, x}, acc -> if is_bitstring(x), do: [x | acc], else: acc
x, acc -> if is_bitstring(x), do: [x | acc], else: acc
end)
|> Enum.uniq()
}
|> add_in_reply_to(draft.in_reply_to)
|> Map.merge(draft.extra)