Transmogrifier: Only add context if it really is onne.
authorlain <lain@soykaf.club>
Tue, 31 Mar 2020 17:16:45 +0000 (19:16 +0200)
committerlain <lain@soykaf.club>
Tue, 31 Mar 2020 17:16:45 +0000 (19:16 +0200)
lib/pleroma/web/activity_pub/transmogrifier.ex

index a3529f09b11a95de45a6b4a05fa62102e8641ee6..f82142979dc561f2ef2b66488ecaa1787f26e67b 100644 (file)
@@ -1255,14 +1255,11 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
     do: {:ok, data}
 
   defp maybe_add_context_from_object(%{"object" => object} = data) when is_binary(object) do
-    if object = Object.normalize(object) do
-      data =
-        data
-        |> Map.put("context", object.data["context"])
-
-      {:ok, data}
+    with %{data: %{"context" => context}} when is_binary(context) <- Object.normalize(object) do
+      {:ok, Map.put(data, "context", context)}
     else
-      {:error, "No context on referenced object"}
+      _ ->
+        {:error, :no_context}
     end
   end