2020-05-18 00:22:26 -06:00
|
|
|
# Pleroma: A lightweight social networking server
|
|
|
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2020-05-15 12:34:46 -06:00
|
|
|
defmodule Pleroma.Web.MediaProxy.Invalidation do
|
2020-05-18 00:22:26 -06:00
|
|
|
@moduledoc false
|
|
|
|
|
2020-05-15 12:34:46 -06:00
|
|
|
@callback purge(list(String.t()), map()) :: {:ok, String.t()} | {:error, String.t()}
|
|
|
|
|
|
|
|
alias Pleroma.Config
|
|
|
|
|
2020-05-18 00:22:26 -06:00
|
|
|
@spec purge(list(String.t())) :: {:ok, String.t()} | {:error, String.t()}
|
2020-05-15 12:34:46 -06:00
|
|
|
def purge(urls) do
|
|
|
|
[:media_proxy, :invalidation, :enabled]
|
|
|
|
|> Config.get()
|
|
|
|
|> do_purge(urls)
|
|
|
|
end
|
|
|
|
|
|
|
|
defp do_purge(true, urls) do
|
2020-05-17 21:48:19 -06:00
|
|
|
provider = Config.get([:media_proxy, :invalidation, :provider])
|
|
|
|
options = Config.get(provider)
|
|
|
|
provider.purge(urls, options)
|
2020-05-15 12:34:46 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
defp do_purge(_, _), do: :ok
|
|
|
|
end
|