aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorWilliam Pitcock <nenolod@dereferenced.org>2019-01-04 23:50:54 +0000
committerWilliam Pitcock <nenolod@dereferenced.org>2019-01-04 23:53:26 +0000
commit487c00d36dee1b975ffc8fca8f0a5bb5510f71a3 (patch)
treeaa6743dea5b6064f8aeef0d2e0a441498dc3fd39 /lib
parent0964c207eb184696355a2d8efd9d671dcc23ce66 (diff)
downloadpleroma-487c00d36dee1b975ffc8fca8f0a5bb5510f71a3.tar.gz
rich media: disable cachex in test mode
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/rich_media/parser.ex15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/pleroma/web/rich_media/parser.ex b/lib/pleroma/web/rich_media/parser.ex
index b88ed5371..3746feaf6 100644
--- a/lib/pleroma/web/rich_media/parser.ex
+++ b/lib/pleroma/web/rich_media/parser.ex
@@ -1,14 +1,17 @@
defmodule Pleroma.Web.RichMedia.Parser do
@parsers [Pleroma.Web.RichMedia.Parsers.OGP]
- def parse(url) do
- Cachex.fetch!(:rich_media_cache, url, fn _ ->
- {:ok, %Tesla.Env{body: html}} = Pleroma.HTTP.get(url)
+ if Mix.env() == :test do
+ def parse(url), do: parse_url(url)
+ else
+ def parse(url),
+ do: {:commit, Cachex.fetch!(:rich_media_cache, url, fn _ -> parse_url(url) end)}
+ end
- result = html |> maybe_parse() |> get_parsed_data()
+ defp parse_url(url) do
+ {:ok, %Tesla.Env{body: html}} = Pleroma.HTTP.get(url)
- {:commit, result}
- end)
+ html |> maybe_parse() |> get_parsed_data()
end
defp maybe_parse(html) do