forked from AkkomaGang/akkoma
Check if mogrify available before calling it
This commit is contained in:
parent
523f1b93a4
commit
3116a75e80
2 changed files with 13 additions and 6 deletions
|
@ -35,9 +35,12 @@ defmodule Pleroma.Upload.Filter.Mogrifun do
|
||||||
]
|
]
|
||||||
|
|
||||||
def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do
|
def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do
|
||||||
Filter.Mogrify.do_filter(file, [Enum.random(@filters)])
|
if Pleroma.Utils.command_available?("mogrify") do
|
||||||
|
Filter.Mogrify.do_filter(file, [Enum.random(@filters)])
|
||||||
:ok
|
:ok
|
||||||
|
else
|
||||||
|
{:error, "mogrify command not found"}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter(_), do: :ok
|
def filter(_), do: :ok
|
||||||
|
|
|
@ -9,10 +9,14 @@ defmodule Pleroma.Upload.Filter.Mogrify do
|
||||||
@type conversions :: conversion() | [conversion()]
|
@type conversions :: conversion() | [conversion()]
|
||||||
|
|
||||||
def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do
|
def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do
|
||||||
filters = Pleroma.Config.get!([__MODULE__, :args])
|
if Pleroma.Utils.command_available?("mogrify") do
|
||||||
|
filters = Pleroma.Config.get!([__MODULE__, :args])
|
||||||
|
|
||||||
do_filter(file, filters)
|
do_filter(file, filters)
|
||||||
:ok
|
:ok
|
||||||
|
else
|
||||||
|
{:error, "mogrify command not found"}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter(_), do: :ok
|
def filter(_), do: :ok
|
||||||
|
|
Loading…
Reference in a new issue