From: William Pitcock <nenolod@dereferenced.org>
Date: Mon, 29 Oct 2018 17:59:24 +0000 (+0000)
Subject: common api: prefer formatting attachments using the attachment's name instead of URI
X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=f407831120318dcd8fa5b31f39137cdb1ee87519;p=akkoma

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

diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex
index ed1fe1ad9..2a5a2cc15 100644
--- a/lib/pleroma/web/common_api/utils.ex
+++ b/lib/pleroma/web/common_api/utils.ex
@@ -89,8 +89,8 @@ defmodule Pleroma.Web.CommonAPI.Utils 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>"