ObjectValidator: Add actor fetcher.
authorlain <lain@soykaf.club>
Thu, 30 Apr 2020 12:13:08 +0000 (14:13 +0200)
committerlain <lain@soykaf.club>
Thu, 30 Apr 2020 12:13:08 +0000 (14:13 +0200)
lib/pleroma/web/activity_pub/object_validator.ex

index f476c6f724a9eec5b8320794a6ef681f5df5b10e..016f6e7a2d253bf5fac5aec49b50774edca13f3e 100644 (file)
@@ -46,8 +46,14 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidator do
     |> Map.new(fn {key, val} -> {to_string(key), val} end)
   end
 
+  def fetch_actor(object) do
+    with {:ok, actor} <- Types.ObjectID.cast(object["actor"]) do
+      User.get_or_fetch_by_ap_id(actor)
+    end
+  end
+
   def fetch_actor_and_object(object) do
-    User.get_or_fetch_by_ap_id(object["actor"])
+    fetch_actor(object)
     Object.normalize(object["object"])
     :ok
   end