X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;ds=inline;f=lib%2Fpleroma%2Fupload%2Ffilter%2Fmogrify.ex;h=f27aefc2252d283451006cc987d45cb541d86b92;hb=6eb7d69e60a96e577de92de232ed48e509f23cd4;hp=91bfdd4f5bdf7157a8036ad9c8ecfe6c78d203f8;hpb=9570a5be405c4cf4f07907eab4ced21e07fa20c9;p=akkoma
diff --git a/lib/pleroma/upload/filter/mogrify.ex b/lib/pleroma/upload/filter/mogrify.ex
index 91bfdd4f5..f27aefc22 100644
--- a/lib/pleroma/upload/filter/mogrify.ex
+++ b/lib/pleroma/upload/filter/mogrify.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Upload.Filter.Mogrify do
@@ -8,14 +8,18 @@ defmodule Pleroma.Upload.Filter.Mogrify do
@type conversion :: action :: String.t() | {action :: String.t(), opts :: String.t()}
@type conversions :: conversion() | [conversion()]
+ @spec filter(Pleroma.Upload.t()) :: {:ok, :atom} | {:error, String.t()}
def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do
- filters = Pleroma.Config.get!([__MODULE__, :args])
-
- do_filter(file, filters)
- :ok
+ try do
+ do_filter(file, Pleroma.Config.get!([__MODULE__, :args]))
+ {:ok, :filtered}
+ rescue
+ e in ErlangError ->
+ {:error, "#{__MODULE__}: #{inspect(e)}"}
+ end
end
- def filter(_), do: :ok
+ def filter(_), do: {:ok, :noop}
def do_filter(file, filters) do
file