common api: prefer formatting attachments using the attachment's name instead of URI

This commit is contained in:
William Pitcock 2018-10-29 17:59:24 +00:00
parent f61acdc5b4
commit f407831120
1 changed files with 2 additions and 2 deletions

View File

@ -89,8 +89,8 @@ def maybe_add_attachments(text, attachments, _no_links) do
def add_attachments(text, attachments) do
attachment_text =
Enum.map(attachments, fn
%{"url" => [%{"href" => href} | _]} ->
name = URI.decode(Path.basename(href))
%{"url" => [%{"href" => href} | _]} = attachment ->
name = attachment["name"] || URI.decode(Path.basename(href))
href = MediaProxy.url(href)
"<a href=\"#{href}\" class='attachment'>#{shortname(name)}</a>"