X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;ds=inline;f=lib%2Fpleroma%2Fupload%2Ffilter%2Fmogrify.ex;h=f27aefc2252d283451006cc987d45cb541d86b92;hb=0db436789dad106c18e1aa4c35bdb856283b4b25;hp=2eb75800659993110500e8d38e1f1abc907fae92;hpb=5992c256ad7c5bc8207240c9d51e03964e50eb64;p=akkoma
diff --git a/lib/pleroma/upload/filter/mogrify.ex b/lib/pleroma/upload/filter/mogrify.ex
index 2eb758006..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-2020 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