diff options
author | lain <lain@soykaf.club> | 2020-05-22 16:05:35 +0000 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-05-22 16:05:35 +0000 |
commit | ddbbefeb2e30afbf86601c4eaf99b5cf00546548 (patch) | |
tree | e271de23edd79bac661898bc2e25e7c14b6a997e /lib | |
parent | 1fa7aa9fc544e9c9b55ecc1a92d93c95eabcfa62 (diff) | |
parent | 5d60b25e690eb21ad2539a10036ba39489f62f97 (diff) | |
download | pleroma-ddbbefeb2e30afbf86601c4eaf99b5cf00546548.tar.gz |
Merge branch 'feature/configure-filename-truncate' into 'develop'
Configurable filename truncation threshold
Closes #1799
See merge request pleroma/pleroma!2573
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/common_api/utils.ex | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index b9fa21648..1c0d90a2b 100644 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@ -396,10 +396,12 @@ defmodule Pleroma.Web.CommonAPI.Utils do def to_masto_date(_), do: "" defp shortname(name) do - if String.length(name) < 30 do - name + with max_length when max_length > 0 <- + Config.get([Pleroma.Upload, :filename_display_max_length], 30), + true <- String.length(name) > max_length do + String.slice(name, 0..max_length) <> "…" else - String.slice(name, 0..30) <> "…" + _ -> name end end |