aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/common_api
diff options
context:
space:
mode:
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>2020-07-31 16:46:35 +0200
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>2020-12-22 05:15:34 +0100
commitacb03d591bea1b20a715201f479f1ad7bf7bb67b (patch)
tree4ec82e0b7116e8accd8c344c5834781f65ac5990 /lib/pleroma/web/common_api
parent8e1f32e71560c4b36ccbdc3ecf8de8386928305a (diff)
downloadpleroma-acb03d591bea1b20a715201f479f1ad7bf7bb67b.tar.gz
Insert text representation of hashtags into object["hashtags"]
Includes a new mix task: pleroma.database fill_old_hashtags
Diffstat (limited to 'lib/pleroma/web/common_api')
-rw-r--r--lib/pleroma/web/common_api/utils.ex11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex
index 1c74ea787..880b5d78f 100644
--- a/lib/pleroma/web/common_api/utils.ex
+++ b/lib/pleroma/web/common_api/utils.ex
@@ -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)