Skip to content
Snippets Groups Projects
Commit 71757933 authored by Haelwenn's avatar Haelwenn
Browse files

Merge branch 'hardening/mastodon-rich-media' into 'develop'

rich media: minor hardening

See merge request pleroma/pleroma!717
parents c410fe96 8f2f471e
No related branches found
No related tags found
No related merge requests found
......@@ -5,11 +5,19 @@ defmodule Pleroma.Web.RichMedia.Parser do
Pleroma.Web.RichMedia.Parsers.OEmbed
]
def parse(nil), do: {:error, "No URL provided"}
if Mix.env() == :test do
def parse(url), do: parse_url(url)
else
def parse(url),
do: Cachex.fetch!(:rich_media_cache, url, fn _ -> parse_url(url) end)
def parse(url) do
with {:ok, data} <- Cachex.fetch(:rich_media_cache, url, fn _ -> parse_url(url) end) do
data
else
_e ->
{:error, "Parsing error"}
end
end
end
defp parse_url(url) do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment