Apply suggestion to lib/pleroma/web/activity_pub/transmogrifier.ex
This commit is contained in:
parent
ecac57732a
commit
1b323ce1c6
1 changed files with 8 additions and 13 deletions
|
@ -1267,24 +1267,19 @@ defp maybe_add_context_from_object(_) do
|
||||||
{:error, :no_context}
|
{:error, :no_context}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp maybe_add_recipients_from_object(%{"object" => object} = data) do
|
defp maybe_add_recipients_from_object(%{"to" => [_ | _], "cc" => [_ | _]} = data), do: {:ok, data}
|
||||||
to = data["to"] || []
|
|
||||||
cc = data["cc"] || []
|
|
||||||
|
|
||||||
if to == [] && cc == [] do
|
defp maybe_add_recipients_from_object(%{"object" => object} = data) do
|
||||||
if object = Object.normalize(object) do
|
case Object.normalize(object) do
|
||||||
|
%{data: {"actor" => actor}} ->
|
||||||
data =
|
data =
|
||||||
data
|
data
|
||||||
|> Map.put("to", [object.data["actor"]])
|
|> Map.put("to", [actor])
|
||||||
|> Map.put("cc", cc)
|
|> Map.put("cc", data["cc"] || [])
|
||||||
|
|
||||||
{:ok, data}
|
{:ok, data}
|
||||||
else
|
nil -> {:error, :no_object}
|
||||||
{:error, "No actor on referenced object"}
|
_ -> {:error, :no_actor}
|
||||||
end
|
|
||||||
else
|
|
||||||
{:ok, data}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
defp maybe_add_recipients_from_object(_) do
|
defp maybe_add_recipients_from_object(_) do
|
||||||
|
|
Loading…
Reference in a new issue