aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorkaniini <ariadne@dereferenced.org>2019-07-14 09:53:42 +0000
committerkaniini <ariadne@dereferenced.org>2019-07-14 09:53:42 +0000
commit9f211838eca3793bac8bbb6b64f200a8a6c8d29f (patch)
treea2c642689f00da2b13069b258f8571f48126db18 /lib
parent592411e4fe8a1cf39064e3dd5f9312ed5cdcd22e (diff)
parent7af27c143d6c6f288be1e7d2fd2e2e9a439ececf (diff)
downloadpleroma-9f211838eca3793bac8bbb6b64f200a8a6c8d29f.tar.gz
Merge branch 'rich_media_parsers_configurable' into 'develop'
parsers configurable See merge request pleroma/pleroma!1400
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/rich_media/parser.ex12
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/pleroma/web/rich_media/parser.ex b/lib/pleroma/web/rich_media/parser.ex
index 21cd47890..0d2523338 100644
--- a/lib/pleroma/web/rich_media/parser.ex
+++ b/lib/pleroma/web/rich_media/parser.ex
@@ -3,12 +3,6 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.RichMedia.Parser do
- @parsers [
- Pleroma.Web.RichMedia.Parsers.OGP,
- Pleroma.Web.RichMedia.Parsers.TwitterCard,
- Pleroma.Web.RichMedia.Parsers.OEmbed
- ]
-
@hackney_options [
pool: :media,
recv_timeout: 2_000,
@@ -16,6 +10,10 @@ defmodule Pleroma.Web.RichMedia.Parser do
with_body: true
]
+ defp parsers do
+ Pleroma.Config.get([:rich_media, :parsers])
+ end
+
def parse(nil), do: {:error, "No URL provided"}
if Pleroma.Config.get(:env) == :test do
@@ -48,7 +46,7 @@ defmodule Pleroma.Web.RichMedia.Parser do
end
defp maybe_parse(html) do
- Enum.reduce_while(@parsers, %{}, fn parser, acc ->
+ Enum.reduce_while(parsers(), %{}, fn parser, acc ->
case parser.parse(html, acc) do
{:ok, data} -> {:halt, data}
{:error, _msg} -> {:cont, acc}