X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fpleroma%2Fweb%2Frich_media%2Fparser.ex;h=d6b54943b40ee2ee0289ef648a1f2cdf4a79a3ba;hb=67ec0e6c18ec6c84fc3aefe9ab883e8f0b01792f;hp=c70d2fdbade7c66a6f253ecbf2e0d3672523e059;hpb=c95859e45b18dec1d00f721ef3c5b4bb1406ea37;p=akkoma
diff --git a/lib/pleroma/web/rich_media/parser.ex b/lib/pleroma/web/rich_media/parser.ex
index c70d2fdba..d6b54943b 100644
--- a/lib/pleroma/web/rich_media/parser.ex
+++ b/lib/pleroma/web/rich_media/parser.ex
@@ -1,10 +1,12 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.RichMedia.Parser do
require Logger
+ @cachex Pleroma.Config.get([:cachex, :provider], Cachex)
+
defp parsers do
Pleroma.Config.get([:rich_media, :parsers])
end
@@ -24,7 +26,7 @@ defmodule Pleroma.Web.RichMedia.Parser do
end
defp get_cached_or_parse(url) do
- case Cachex.fetch(:rich_media_cache, url, fn ->
+ case @cachex.fetch(:rich_media_cache, url, fn ->
case parse_url(url) do
{:ok, _} = res ->
{:commit, res}
@@ -64,7 +66,7 @@ defmodule Pleroma.Web.RichMedia.Parser do
defp set_error_ttl(url, _reason) do
ttl = Pleroma.Config.get([:rich_media, :failure_backoff], 60_000)
- Cachex.expire(:rich_media_cache, url, ttl)
+ @cachex.expire(:rich_media_cache, url, ttl)
:ok
end
@@ -106,7 +108,7 @@ defmodule Pleroma.Web.RichMedia.Parser do
{:ok, ttl} when is_number(ttl) ->
ttl = ttl * 1000
- case Cachex.expire_at(:rich_media_cache, url, ttl) do
+ case @cachex.expire_at(:rich_media_cache, url, ttl) do
{:ok, true} -> {:ok, ttl}
{:ok, false} -> {:error, :no_key}
end