fix case when tags is invalid

This commit is contained in:
Maksim Pechnikov 2018-12-14 22:56:37 +03:00
commit ea72ac549b
2 changed files with 15 additions and 2 deletions

View file

@ -244,8 +244,10 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
{"name": "nextcloud", "url": "/tag/nextcloud"}]
"""
@spec build_tags(list(String.t())) :: list(map())
@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)