Transmogrifier: Handle `Update` with the pipeline.
authorlain <lain@soykaf.club>
Mon, 22 Jun 2020 11:16:05 +0000 (13:16 +0200)
committerlain <lain@soykaf.club>
Mon, 22 Jun 2020 11:16:05 +0000 (13:16 +0200)
lib/pleroma/web/activity_pub/transmogrifier.ex

index 851f474b88c060c44aad6d2ad7c5b04e90a46289..8165218eee45feb39d1201c0f6e7a026dc44b3e6 100644 (file)
@@ -684,35 +684,12 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
   end
 
   def handle_incoming(
-        %{"type" => "Update", "object" => %{"type" => object_type} = object, "actor" => actor_id} =
-          data,
+        %{"type" => "Update"} = data,
         _options
-      )
-      when object_type in [
-             "Person",
-             "Application",
-             "Service",
-             "Organization"
-           ] do
-    with %User{ap_id: ^actor_id} = actor <- User.get_cached_by_ap_id(object["id"]) do
-      {:ok, new_user_data} = ActivityPub.user_data_from_user_object(object)
-
-      actor
-      |> User.remote_user_changeset(new_user_data)
-      |> User.update_and_set_cache()
-
-      ActivityPub.update(%{
-        local: false,
-        to: data["to"] || [],
-        cc: data["cc"] || [],
-        object: object,
-        actor: actor_id,
-        activity_id: data["id"]
-      })
-    else
-      e ->
-        Logger.error(e)
-        :error
+      ) do
+    with {:ok, %User{}} <- ObjectValidator.fetch_actor(data),
+         {:ok, activity, _} <- Pipeline.common_pipeline(data, local: false) do
+      {:ok, activity}
     end
   end