summaryrefslogtreecommitdiff
path: root/lib/pleroma/web/rich_media/parser/ttl.ex
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pleroma/web/rich_media/parser/ttl.ex')
-rw-r--r--lib/pleroma/web/rich_media/parser/ttl.ex15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/pleroma/web/rich_media/parser/ttl.ex b/lib/pleroma/web/rich_media/parser/ttl.ex
index d69bb0d07..7e56375ff 100644
--- a/lib/pleroma/web/rich_media/parser/ttl.ex
+++ b/lib/pleroma/web/rich_media/parser/ttl.ex
@@ -5,15 +5,16 @@
defmodule Pleroma.Web.RichMedia.Parser.TTL do
@callback ttl(map(), String.t()) :: integer() | nil
- def get_from_image(data, url) do
+ @spec process(map(), String.t()) :: {:ok, integer() | nil}
+ def process(data, url) do
[:rich_media, :ttl_setters]
|> Pleroma.Config.get()
- |> Enum.reduce({:ok, nil}, fn
- module, {:ok, _ttl} ->
- module.ttl(data, url)
-
- _, error ->
- error
+ |> Enum.reduce_while({:ok, nil}, fn
+ module, acc ->
+ case module.ttl(data, url) do
+ ttl when is_number(ttl) -> {:halt, {:ok, ttl}}
+ _ -> {:cont, acc}
+ end
end)
end
end