aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHaelwenn <contact+git.pleroma.social@hacktivis.me>2020-08-18 19:02:33 +0000
committerHaelwenn <contact+git.pleroma.social@hacktivis.me>2020-08-18 19:02:33 +0000
commit3d5d8c05c9de9a70a8d49576f125b9987f9d34e8 (patch)
tree44de972a82f2593b9d34378ddecb2acaf229be08 /lib
parentfa8a87eca1892b094e5faafc48404dd1a75e4a57 (diff)
parent52a79506c786a1388eeab24892c7b36ee9682977 (diff)
downloadpleroma-3d5d8c05c9de9a70a8d49576f125b9987f9d34e8.tar.gz
Merge branch '2064-image-blanking' into 'develop'
Resolve "Make default image description blank" Closes #2064 See merge request pleroma/pleroma!2899
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/upload.ex11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/pleroma/upload.ex b/lib/pleroma/upload.ex
index 0fa6b89dc..015c87593 100644
--- a/lib/pleroma/upload.ex
+++ b/lib/pleroma/upload.ex
@@ -56,6 +56,15 @@ defmodule Pleroma.Upload do
}
defstruct [:id, :name, :tempfile, :content_type, :path]
+ defp get_description(opts, upload) do
+ case {opts[:description], Pleroma.Config.get([Pleroma.Upload, :default_description])} do
+ {description, _} when is_binary(description) -> description
+ {_, :filename} -> upload.name
+ {_, str} when is_binary(str) -> str
+ _ -> ""
+ end
+ end
+
@spec store(source, options :: [option()]) :: {:ok, Map.t()} | {:error, any()}
def store(upload, opts \\ []) do
opts = get_opts(opts)
@@ -63,7 +72,7 @@ defmodule Pleroma.Upload do
with {:ok, upload} <- prepare_upload(upload, opts),
upload = %__MODULE__{upload | path: upload.path || "#{upload.id}/#{upload.name}"},
{:ok, upload} <- Pleroma.Upload.Filter.filter(opts.filters, upload),
- description = Map.get(opts, :description) || upload.name,
+ description = get_description(opts, upload),
{_, true} <-
{:description_limit,
String.length(description) <= Pleroma.Config.get([:instance, :description_limit])},