Make rich media support toggleable
authorrinpatch <rinpatch@sdf.org>
Thu, 31 Jan 2019 15:18:20 +0000 (18:18 +0300)
committerrinpatch <rinpatch@sdf.org>
Thu, 31 Jan 2019 15:18:20 +0000 (18:18 +0300)
config/config.exs
docs/config.md
lib/pleroma/web/rich_media/helpers.ex

index 4dc7a62d72824b84fb813c46b73295d1274a73fc..98c94c14922c72c262b9de091eb7bb3e6740d9fe 100644 (file)
@@ -235,6 +235,8 @@ config :pleroma, :mrf_simple,
   reject: [],
   accept: []
 
+config :pleroma, :rich_media, enabled: true
+
 config :pleroma, :media_proxy,
   enabled: false,
   proxy_opts: [
index 4f4a4378c1f0405f5c48b02100291d40e6678b25..902c1e18850b34aeac02546baf23f2056f9af5cc 100644 (file)
@@ -235,6 +235,9 @@ curl "http://localhost:4000/api/pleroma/admin/invite_token?admin_token=somerando
   * Pleroma.Web.Metadata.Providers.TwitterCard
 * `unfurl_nsfw`: If set to `true` nsfw attachments will be shown in previews
 
+## :rich_media
+* `enabled`: if enabled the instance will parse metadata from attached links to generate link previews
+
 ## :hackney_pools
 
 Advanced. Tweaks Hackney (http client) connections pools.
index 71fdddef9674a3ebb40fa32a52d9e084e036d374..44e876777c92ce93b1cbdd4c1ae3a9c6fb466130 100644 (file)
@@ -7,7 +7,8 @@ defmodule Pleroma.Web.RichMedia.Helpers do
   alias Pleroma.Web.RichMedia.Parser
 
   def fetch_data_for_activity(%Activity{} = activity) do
-    with %Object{} = object <- Object.normalize(activity.data["object"]),
+    with true <- Pleroma.Config.get([:rich_media, :enabled], true),
+         %Object{} = object <- Object.normalize(activity.data["object"]),
          {:ok, page_url} <- HTML.extract_first_external_url(object, object.data["content"]),
          {:ok, rich_media} <- Parser.parse(page_url) do
       %{page_url: page_url, rich_media: rich_media}