total rebase
[anni] / lib / pleroma / web / rich_media / parser / ttl.ex
old mode 100755 (executable)
new mode 100644 (file)
index 59d7f87..7e56375
@@ -3,5 +3,18 @@
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Web.RichMedia.Parser.TTL do
-  @callback ttl(Map.t(), String.t()) :: Integer.t() | nil
+  @callback ttl(map(), String.t()) :: integer() | nil
+
+  @spec process(map(), String.t()) :: {:ok, integer() | nil}
+  def process(data, url) do
+    [:rich_media, :ttl_setters]
+    |> Pleroma.Config.get()
+    |> 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