rich media: helpers: only crawl Create activities
authorWilliam Pitcock <nenolod@dereferenced.org>
Sat, 23 Mar 2019 02:26:49 +0000 (02:26 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Sat, 23 Mar 2019 02:28:59 +0000 (02:28 +0000)
lib/pleroma/web/rich_media/helpers.ex

index f97d1863c4505f524369a38df424404c3bc6c441..f67aaf58b655af4cfbe714f0b9b9810aacc2585c 100644 (file)
@@ -21,7 +21,7 @@ defmodule Pleroma.Web.RichMedia.Helpers do
   defp validate_page_url(%URI{}), do: :ok
   defp validate_page_url(_), do: :error
 
-  def fetch_data_for_activity(%Activity{} = activity) do
+  def fetch_data_for_activity(%Activity{data: %{"type" => "Create"}} = activity) do
     with true <- Pleroma.Config.get([:rich_media, :enabled]),
          %Object{} = object <- Object.normalize(activity),
          {:ok, page_url} <- HTML.extract_first_external_url(object, object.data["content"]),
@@ -32,4 +32,6 @@ defmodule Pleroma.Web.RichMedia.Helpers do
       _ -> %{}
     end
   end
+
+  def fetch_data_for_activity(_), do: %{}
 end