diff options
Diffstat (limited to 'lib/pleroma/web/twitter_api/utils.ex')
-rw-r--r-- | lib/pleroma/web/twitter_api/utils.ex | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/pleroma/web/twitter_api/utils.ex b/lib/pleroma/web/twitter_api/utils.ex index cd7e04ca1..055588031 100644 --- a/lib/pleroma/web/twitter_api/utils.ex +++ b/lib/pleroma/web/twitter_api/utils.ex @@ -9,10 +9,19 @@ defmodule Pleroma.Web.TwitterAPI.Utils do end) end + defp shortname(name) do + if String.length(name) < 30 do + name + else + String.slice(name, 0..30) <> "…" + end + end + def add_attachments(text, attachments) do attachment_text = Enum.map(attachments, fn (%{"url" => [%{"href" => href} | _]}) -> - "<a href=\"#{href}\" class='attachment'>#{Path.basename(href)}</a>" + name = URI.decode(Path.basename(href)) + "<a href=\"#{href}\" class='attachment'>#{shortname(name)}</a>" _ -> "" end) Enum.join([text | attachment_text], "<br>\n") |