Make sure activity recipient can't be nil
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
888d2ef4b8
commit
3b8b150d48
@ -110,6 +110,9 @@ defmodule Mobilizon.Federation.ActivityPub.Publisher do
|
||||
@spec convert_followers_in_recipients(list(String.t())) :: {list(String.t()), list(String.t())}
|
||||
defp convert_followers_in_recipients(recipients) do
|
||||
Enum.reduce(recipients, {recipients, []}, fn recipient, {recipients, follower_actors} = acc ->
|
||||
if is_nil(recipient) do
|
||||
acc
|
||||
else
|
||||
case Actors.get_actor_by_followers_url(recipient) do
|
||||
%Actor{} = group ->
|
||||
{Enum.filter(recipients, fn recipient -> recipient != group.followers_url end),
|
||||
@ -118,6 +121,7 @@ defmodule Mobilizon.Federation.ActivityPub.Publisher do
|
||||
nil ->
|
||||
acc
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
@ -128,6 +132,9 @@ defmodule Mobilizon.Federation.ActivityPub.Publisher do
|
||||
@spec convert_members_in_recipients(list(String.t())) :: {list(String.t()), list(Actor.t())}
|
||||
defp convert_members_in_recipients(recipients) do
|
||||
Enum.reduce(recipients, {recipients, []}, fn recipient, {recipients, member_actors} = acc ->
|
||||
if is_nil(recipient) do
|
||||
acc
|
||||
else
|
||||
case Actors.get_group_by_members_url(recipient) do
|
||||
# If the group is local just add external members
|
||||
%Actor{domain: domain} = group when is_nil(domain) ->
|
||||
@ -142,6 +149,7 @@ defmodule Mobilizon.Federation.ActivityPub.Publisher do
|
||||
_ ->
|
||||
acc
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user