From 171ef33cbbdd96f2fb7c893be899f7e13c64a449 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Mon, 28 Aug 2017 19:17:38 +0200 Subject: More sensible attachment names. --- lib/pleroma/web/twitter_api/utils.ex | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'lib') 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} | _]}) -> - "#{Path.basename(href)}" + name = URI.decode(Path.basename(href)) + "#{shortname(name)}" _ -> "" end) Enum.join([text | attachment_text], "
\n") -- cgit v1.2.3