Only fetch if it's http.
authorlain <lain@soykaf.club>
Mon, 19 Mar 2018 09:28:28 +0000 (10:28 +0100)
committerlain <lain@soykaf.club>
Mon, 19 Mar 2018 09:28:28 +0000 (10:28 +0100)
lib/pleroma/web/activity_pub/activity_pub.ex
lib/pleroma/web/ostatus/ostatus.ex

index 965f2cc9b0ad0af935c807f52f24b34bcb3ddb95..414b09291308a8c0c619dcb50bca27d6daa2dc2f 100644 (file)
@@ -361,7 +361,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
       {:ok, object}
     else
       Logger.info("Fetching #{id} via AP")
-      with {:ok, %{body: body, status_code: code}} when code in 200..299 <- @httpoison.get(id, [Accept: "application/activity+json"], follow_redirect: true, timeout: 10000, recv_timeout: 20000),
+      with true <- String.starts_with?(id, "http"),
+           {:ok, %{body: body, status_code: code}} when code in 200..299 <- @httpoison.get(id, [Accept: "application/activity+json"], follow_redirect: true, timeout: 10000, recv_timeout: 20000),
            {:ok, data} <- Poison.decode(body),
            nil <- Object.get_by_ap_id(data["id"]),
            params <- %{"type" => "Create", "to" => data["to"], "cc" => data["cc"], "actor" => data["attributedTo"], "object" => data},
index bed15e8c049116febcb977f353e4b0974b4a3ff5..d712bce6c11abff3f2c66ecf92c3587229137598 100644 (file)
@@ -297,7 +297,8 @@ defmodule Pleroma.Web.OStatus do
   end
 
   def fetch_activity_from_atom_url(url) do
-    with {:ok, %{body: body, status_code: code}} when code in 200..299 <- @httpoison.get(url, [Accept: "application/atom+xml"], follow_redirect: true, timeout: 10000, recv_timeout: 20000) do
+    with true <- String.starts_with?(url, "http"),
+         {:ok, %{body: body, status_code: code}} when code in 200..299 <- @httpoison.get(url, [Accept: "application/atom+xml"], follow_redirect: true, timeout: 10000, recv_timeout: 20000) do
       Logger.debug("Got document from #{url}, handling...")
       handle_incoming(body)
     else
@@ -309,7 +310,8 @@ defmodule Pleroma.Web.OStatus do
 
   def fetch_activity_from_html_url(url) do
     Logger.debug("Trying to fetch #{url}")
-    with {:ok, %{body: body}} <- @httpoison.get(url, [], follow_redirect: true, timeout: 10000, recv_timeout: 20000),
+    with true <- String.starts_with?(url, "http"),
+         {:ok, %{body: body}} <- @httpoison.get(url, [], follow_redirect: true, timeout: 10000, recv_timeout: 20000),
          {:ok, atom_url} <- get_atom_url(body) do
         fetch_activity_from_atom_url(atom_url)
     else