aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMaksim Pechnikov <parallel588@gmail.com>2018-12-13 15:13:02 +0300
committerMaksim Pechnikov <parallel588@gmail.com>2018-12-14 22:09:04 +0300
commitd3ec09bb380bb990bea6edc5dae6bbda7f2322c5 (patch)
tree82ace98293e3da35f633e417e9c217fe69c1c4f5 /lib
parent91236c60c7aa266c1e874ebdd2aa44becfc6709b (diff)
downloadpleroma-d3ec09bb380bb990bea6edc5dae6bbda7f2322c5.tar.gz
fix tags
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/mastodon_api/views/status_view.ex21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex
index c3c735d5d..f2a47f594 100644
--- a/lib/pleroma/web/mastodon_api/views/status_view.ex
+++ b/lib/pleroma/web/mastodon_api/views/status_view.ex
@@ -140,7 +140,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
visibility: get_visibility(object),
media_attachments: attachments |> Enum.take(4),
mentions: mentions,
- tags: tags,
+ tags: build_tags(tags),
application: %{
name: "Web",
website: nil
@@ -235,6 +235,25 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
def render_content(object), do: object["content"] || ""
@doc """
+ Builds a dictionary tags.
+
+ ## Examples
+
+ iex> Pleroma.Web.MastodonAPI.StatusView.build_tags(["fediverse", "nextcloud"])
+ [{"name": "fediverse", "url": "/tag/fediverse"},
+ {"name": "nextcloud", "url": "/tag/nextcloud"}]
+
+ """
+ @spec build_tags(list(String.t())) :: list(map())
+ def build_tags(object_tags) when is_list(object_tags) do
+ Enum.reduce(object_tags, [], fn tag, tags ->
+ tags ++ [%{name: tag, url: "/tag/#{tag}"}]
+ end)
+ end
+
+ def build_tags(_), do: []
+
+ @doc """
Builds list emojis.
Arguments: `nil` or list tuple of name and url.