Handle suspending actors with special type
Closes #1183 Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
bb86ca5413
commit
af3110955d
|
@ -22,6 +22,7 @@ defmodule Mobilizon.Service.ActorSuspension do
|
||||||
|
|
||||||
@actor_preloads [:user, :organized_events, :participations, :comments]
|
@actor_preloads [:user, :organized_events, :participations, :comments]
|
||||||
@delete_actor_default_options [reserve_username: true, suspension: false]
|
@delete_actor_default_options [reserve_username: true, suspension: false]
|
||||||
|
@valid_actor_types [:Person, :Group]
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Deletes an actor.
|
Deletes an actor.
|
||||||
|
@ -119,7 +120,8 @@ defmodule Mobilizon.Service.ActorSuspension do
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec notify_event_participants_from_suspension(Actor.t()) :: :ok
|
@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
|
actor
|
||||||
|> get_actor_organizer_events_participations()
|
|> get_actor_organizer_events_participations()
|
||||||
|> preload([:actor, :event])
|
|> preload([:actor, :event])
|
||||||
|
@ -134,6 +136,8 @@ defmodule Mobilizon.Service.ActorSuspension do
|
||||||
|> Enum.each(&Events.delete_participant/1)
|
|> Enum.each(&Events.delete_participant/1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp notify_event_participants_from_suspension(_), do: :ok
|
||||||
|
|
||||||
@spec get_actor_organizer_events_participations(Actor.t()) :: Ecto.Query.t()
|
@spec get_actor_organizer_events_participations(Actor.t()) :: Ecto.Query.t()
|
||||||
defp get_actor_organizer_events_participations(%Actor{type: :Person, id: actor_id}) do
|
defp get_actor_organizer_events_participations(%Actor{type: :Person, id: actor_id}) do
|
||||||
do_get_actor_organizer_events_participations()
|
do_get_actor_organizer_events_participations()
|
||||||
|
|
Loading…
Reference in a new issue