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

View File

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