diff options
author | href <href+git-pleroma@random.sh> | 2018-12-14 20:20:30 +0000 |
---|---|---|
committer | href <href+git-pleroma@random.sh> | 2018-12-14 20:20:30 +0000 |
commit | acec11626d2bb61c3728d634b04ac5afeaf4b17b (patch) | |
tree | ec90d7a92caec4981aacfc509f8eddca18d3393d /lib | |
parent | 980131b4db4f2da319d9054889bdb962aa8c837e (diff) | |
parent | ea72ac549b2ac52623462d6862154fb6f800c01c (diff) | |
download | pleroma-acec11626d2bb61c3728d634b04ac5afeaf4b17b.tar.gz |
Merge branch 'fix/issue_272' into 'develop'
[#272] fix tags
See merge request pleroma/pleroma!540
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/mastodon_api/views/status_view.ex | 23 |
1 files changed, 22 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..46c559e3a 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,27 @@ 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(any())) :: list(map()) + def build_tags(object_tags) when is_list(object_tags) do + object_tags = for tag when is_binary(tag) <- object_tags, do: tag + + 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. |