1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.MediaProxy.Invalidation do
8 @callback purge(list(String.t()), Keyword.t()) :: {:ok, list(String.t())} | {:error, String.t()}
11 alias Pleroma.Web.MediaProxy
13 @spec enabled?() :: boolean()
14 def enabled?, do: Config.get([:media_proxy, :invalidation, :enabled])
16 @spec purge(list(String.t()) | String.t()) :: {:ok, list(String.t())} | {:error, String.t()}
18 prepared_urls = prepare_urls(urls)
21 do_purge(prepared_urls)
27 defp do_purge(urls) do
28 provider = Config.get([:media_proxy, :invalidation, :provider])
29 options = Config.get(provider)
30 provider.purge(urls, options)
33 def prepare_urls(urls) do
36 |> Enum.map(fn url -> [MediaProxy.url(url), MediaProxy.preview_url(url)] end)