diff options
author | Mark Felder <feld@FreeBSD.org> | 2020-08-26 16:37:25 -0500 |
---|---|---|
committer | Mark Felder <feld@FreeBSD.org> | 2020-08-26 16:37:25 -0500 |
commit | c199e18bb5b1a923029248783c60acf7c9597f64 (patch) | |
tree | eaae6461c41c5ed526cc1a7cb106c6c881cafcb4 /lib/pleroma/upload.ex | |
parent | 98f8851f29f940051656caa1715820bce70f8c29 (diff) | |
parent | 6f17aea066498bf070f0decb3ac0508c6b04e3b8 (diff) | |
download | pleroma-2168-media-preview-proxy.tar.gz |
Merge branch 'develop' into 2168-media-preview-proxy2168-media-preview-proxy
Diffstat (limited to 'lib/pleroma/upload.ex')
-rw-r--r-- | lib/pleroma/upload.ex | 11 |
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])}, |