ActivityPub: Small refactor.
authorlain <lain@soykaf.club>
Thu, 26 Mar 2020 14:16:54 +0000 (15:16 +0100)
committerlain <lain@soykaf.club>
Thu, 26 Mar 2020 14:16:54 +0000 (15:16 +0100)
lib/pleroma/web/activity_pub/activity_pub.ex

index dd4b04185c97603175f4d6552c9e6465533d11a9..35c2eb133c0bd9fcdea34b0aa8667138873b80be 100644 (file)
@@ -129,18 +129,17 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
   # TODO rewrite in with style
   @spec persist(map(), keyword()) :: {:ok, Activity.t() | Object.t()}
   def persist(object, meta) do
-    local = Keyword.fetch!(meta, :local)
-    {recipients, _, _} = get_recipients(object)
-
-    {:ok, activity} =
-      Repo.insert(%Activity{
-        data: object,
-        local: local,
-        recipients: recipients,
-        actor: object["actor"]
-      })
-
-    {:ok, activity, meta}
+    with local <- Keyword.fetch!(meta, :local),
+         {recipients, _, _} <- get_recipients(object),
+         {:ok, activity} <-
+           Repo.insert(%Activity{
+             data: object,
+             local: local,
+             recipients: recipients,
+             actor: object["actor"]
+           }) do
+      {:ok, activity, meta}
+    end
   end
 
   def insert(map, local \\ true, fake \\ false, bypass_actor_check \\ false) when is_map(map) do