projects
/
akkoma
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
a35b764
)
Types.Recipients: Simplify reducer.
author
lain
<lain@soykaf.club>
Sun, 3 May 2020 13:28:24 +0000
(15:28 +0200)
committer
lain
<lain@soykaf.club>
Sun, 3 May 2020 13:28:24 +0000
(15:28 +0200)
lib/pleroma/web/activity_pub/object_validators/types/recipients.ex
patch
|
blob
|
history
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 48fe61e1a9793e289fb98343c32f48c042e503fb..408e0f6ee6e114521a85aabf0f8dabed9cdbafcb 100644
(file)
--- 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