From: lain Date: Thu, 30 Apr 2020 12:13:08 +0000 (+0200) Subject: ObjectValidator: Add actor fetcher. X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=42ce7c5164326aa577bc7bd18e98c5d0a9d6fea5;p=akkoma ObjectValidator: Add actor fetcher. --- diff --git a/lib/pleroma/web/activity_pub/object_validator.ex b/lib/pleroma/web/activity_pub/object_validator.ex index f476c6f72..016f6e7a2 100644 --- a/lib/pleroma/web/activity_pub/object_validator.ex +++ b/lib/pleroma/web/activity_pub/object_validator.ex @@ -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