Handle suspending actors with special type

Closes #1183

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2022-11-07 19:07:36 +01:00
parent bb86ca5413
commit af3110955d
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773

View File

@ -22,6 +22,7 @@ defmodule Mobilizon.Service.ActorSuspension do
@actor_preloads [:user, :organized_events, :participations, :comments]
@delete_actor_default_options [reserve_username: true, suspension: false]
@valid_actor_types [:Person, :Group]
@doc """
Deletes an actor.
@ -119,7 +120,8 @@ defmodule Mobilizon.Service.ActorSuspension do
end
@spec notify_event_participants_from_suspension(Actor.t()) :: :ok
defp notify_event_participants_from_suspension(%Actor{id: actor_id} = actor) do
defp notify_event_participants_from_suspension(%Actor{id: actor_id, type: actor_type} = actor)
when actor_type in @valid_actor_types do
actor
|> get_actor_organizer_events_participations()
|> preload([:actor, :event])
@ -134,6 +136,8 @@ defmodule Mobilizon.Service.ActorSuspension do
|> Enum.each(&Events.delete_participant/1)
end
defp notify_event_participants_from_suspension(_), do: :ok
@spec get_actor_organizer_events_participations(Actor.t()) :: Ecto.Query.t()
defp get_actor_organizer_events_participations(%Actor{type: :Person, id: actor_id}) do
do_get_actor_organizer_events_participations()