Commit 1b323ce1 authored by lain's avatar lain

Apply suggestion to lib/pleroma/web/activity_pub/transmogrifier.ex

parent ecac5773
Pipeline #24070 failed with stages
in 27 seconds
......@@ -1267,24 +1267,19 @@ defp maybe_add_context_from_object(_) do
{:error, :no_context}
end
defp maybe_add_recipients_from_object(%{"object" => object} = data) do
to = data["to"] || []
cc = data["cc"] || []
defp maybe_add_recipients_from_object(%{"to" => [_ | _], "cc" => [_ | _]} = data), do: {:ok, data}
if to == [] && cc == [] do
if object = Object.normalize(object) do
defp maybe_add_recipients_from_object(%{"object" => object} = data) do
case Object.normalize(object) do
%{data: {"actor" => actor}} ->
data =
data
|> Map.put("to", [object.data["actor"]])
|> Map.put("cc", cc)
|> Map.put("to", [actor])
|> Map.put("cc", data["cc"] || [])
{:ok, data}
else
{:error, "No actor on referenced object"}
end
else
{:ok, data}
end
nil -> {:error, :no_object}
_ -> {:error, :no_actor}
end
defp maybe_add_recipients_from_object(_) do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment