Class: Decidim::Admin::ParticipatorySpace::DestroyMembersFollowsJob
- Inherits:
-
ApplicationJob
- Object
- Decidim::ApplicationJob
- ApplicationJob
- Decidim::Admin::ParticipatorySpace::DestroyMembersFollowsJob
- Defined in:
- app/jobs/decidim/admin/participatory_space/destroy_members_follows_job.rb
Instance Method Summary collapse
Instance Method Details
#destroy_children_follows(follows, space) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'app/jobs/decidim/admin/participatory_space/destroy_members_follows_job.rb', line 25 def destroy_children_follows(follows, space) follows.map do |follow| object = follow.followable.presence next unless object.respond_to?(:decidim_component_id) follow.destroy if space.component_ids.include?(object.decidim_component_id) end end |
#perform(decidim_user_id, space) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/jobs/decidim/admin/participatory_space/destroy_members_follows_job.rb', line 9 def perform(decidim_user_id, space) return unless space.respond_to?(:restricted?) && space.restricted? return if space.respond_to?(:transparent?) && space.transparent? user = Decidim::User.find_by(id: decidim_user_id) return if user.blank? return if space.respond_to?(:can_participate?) && space.can_participate?(user) follows = Decidim::Follow.where(user:) follows.where(followable: space).destroy_all destroy_children_follows(follows, space) end |