diff options
author | lain <lain@soykaf.club> | 2020-05-03 15:28:24 +0200 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-05-03 15:28:24 +0200 |
commit | 9249742f13445f47167d4b352751c49caf48aa8f (patch) | |
tree | 973ebdaa1efd0901d0131b66d161668d4814894b /lib | |
parent | a35b76431ce7c7bd7ed62374d781778922f0fe2f (diff) | |
download | pleroma-9249742f13445f47167d4b352751c49caf48aa8f.tar.gz |
Types.Recipients: Simplify reducer.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/activity_pub/object_validators/types/recipients.ex | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/pleroma/web/activity_pub/object_validators/types/recipients.ex b/lib/pleroma/web/activity_pub/object_validators/types/recipients.ex index 48fe61e1a..408e0f6ee 100644 --- a/lib/pleroma/web/activity_pub/object_validators/types/recipients.ex +++ b/lib/pleroma/web/activity_pub/object_validators/types/recipients.ex @@ -11,11 +11,13 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.Types.Recipients do def cast(data) when is_list(data) do data - |> Enum.reduce({:ok, []}, fn element, acc -> - case {acc, ObjectID.cast(element)} do - {:error, _} -> :error - {_, :error} -> :error - {{:ok, list}, {:ok, id}} -> {:ok, [id | list]} + |> Enum.reduce_while({:ok, []}, fn element, {:ok, list} -> + case ObjectID.cast(element) do + {:ok, id} -> + {:cont, {:ok, [id | list]}} + + _ -> + {:halt, :error} end end) end |