From c62220c50078c648c33d7aad7a615b9c7e1f27c6 Mon Sep 17 00:00:00 2001
From: William Pitcock <nenolod@dereferenced.org>
Date: Sat, 23 Mar 2019 02:26:49 +0000
Subject: [PATCH] rich media: helpers: only crawl Create activities

---
 lib/pleroma/web/rich_media/helpers.ex | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/pleroma/web/rich_media/helpers.ex b/lib/pleroma/web/rich_media/helpers.ex
index f97d1863c..f67aaf58b 100644
--- a/lib/pleroma/web/rich_media/helpers.ex
+++ b/lib/pleroma/web/rich_media/helpers.ex
@@ -21,7 +21,7 @@ defp validate_page_url(%URI{scheme: nil}), do: :error
   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 @@ def fetch_data_for_activity(%Activity{} = activity) do
       _ -> %{}
     end
   end
+
+  def fetch_data_for_activity(_), do: %{}
 end