From: rinpatch Date: Thu, 31 Jan 2019 15:18:20 +0000 (+0300) Subject: Make rich media support toggleable X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=7057891db649e1a72abfda13418d8c4bddd4ec92;p=akkoma Make rich media support toggleable --- diff --git a/config/config.exs b/config/config.exs index 4dc7a62d7..98c94c149 100644 --- a/config/config.exs +++ b/config/config.exs @@ -235,6 +235,8 @@ config :pleroma, :mrf_simple, reject: [], accept: [] +config :pleroma, :rich_media, enabled: true + config :pleroma, :media_proxy, enabled: false, proxy_opts: [ diff --git a/docs/config.md b/docs/config.md index 4f4a4378c..902c1e188 100644 --- a/docs/config.md +++ b/docs/config.md @@ -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. diff --git a/lib/pleroma/web/rich_media/helpers.ex b/lib/pleroma/web/rich_media/helpers.ex index 71fdddef9..44e876777 100644 --- a/lib/pleroma/web/rich_media/helpers.ex +++ b/lib/pleroma/web/rich_media/helpers.ex @@ -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}