fetcher: move local object checking into a reusable function
authorrinpatch <rinpatch@sdf.org>
Sat, 23 Nov 2019 19:55:41 +0000 (22:55 +0300)
committerrinpatch <rinpatch@sdf.org>
Sat, 23 Nov 2019 19:55:41 +0000 (22:55 +0300)
lib/pleroma/object.ex
lib/pleroma/object/fetcher.ex

index cde0eddd9e8d72267f4522d5c825d87a50db1a23..b4ed3a9b2d1ba7b0004e213f0924009cb081bc8c 100644 (file)
@@ -255,4 +255,8 @@ defmodule Pleroma.Object do
     |> Object.change(%{data: Map.merge(data || %{}, attrs)})
     |> Repo.update()
   end
+
+  def local?(%Object{data: %{"id" => id}}) do
+    String.starts_with?(id, Pleroma.Web.base_url() <> "/")
+  end
 end
index 9a9a4655005d5ab8dcb21511e11ebda5ca7d73a7..4d71c91a80be38f5470690048495c3d4f8ba227c 100644 (file)
@@ -49,7 +49,7 @@ defmodule Pleroma.Object.Fetcher do
   end
 
   def refetch_object(%Object{data: %{"id" => id}} = object) do
-    with {:local, false} <- {:local, String.starts_with?(id, Pleroma.Web.base_url() <> "/")},
+    with {:local, false} <- {:local, Object.local?(object)},
          {:ok, data} <- fetch_and_contain_remote_object_from_id(id),
          {:ok, object} <- reinject_object(object, data) do
       {:ok, object}