diff options
author | Haelwenn <contact+git.pleroma.social@hacktivis.me> | 2020-12-28 10:14:58 +0000 |
---|---|---|
committer | Haelwenn <contact+git.pleroma.social@hacktivis.me> | 2020-12-28 10:14:58 +0000 |
commit | b122b6ffa318af30586f9da0532135959804a6a0 (patch) | |
tree | ec01ebec0ec8877af9e4876c3627e0756677e081 /lib/pleroma/web/common_api | |
parent | e4f1d8f48c85b8a388d6c3945db157de5ce588c5 (diff) | |
parent | d0c2479710b40a88b3a74c85c9ed9e72e9a2bfaf (diff) | |
download | pleroma-b122b6ffa318af30586f9da0532135959804a6a0.tar.gz |
Merge branch 'features/hashtag-column' into 'develop'
Insert text representation of hashtags into object["hashtags"]
See merge request pleroma/pleroma!2824
Diffstat (limited to 'lib/pleroma/web/common_api')
-rw-r--r-- | lib/pleroma/web/common_api/utils.ex | 11 |
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) |