lib/decidim/cdtb/users/remover.rb in decidim-cdtb-0.1.7 vs lib/decidim/cdtb/users/remover.rb in decidim-cdtb-0.1.8

- old
+ new

@@ -3,10 +3,11 @@ module Decidim module Cdtb module Users # Remove Decidim::User's # + # rubocop:disable Metrics/ClassLength class Remover < ::Decidim::Cdtb::Task def initialize(csv_path, reporter_user_email) @csv_path = csv_path @reporter_user_email = reporter_user_email progress_bar = { title: "Decidim::User" } @@ -42,10 +43,11 @@ private def manage_comments(comments, user, reporter_user) comments.find_each do |comment| report_comment(comment, user, reporter_user) + hide_comment(comment, user, reporter_user) unless comment.hidden? end end def block_user(user, reporter_user) params = { @@ -109,17 +111,30 @@ puts "ERROR: Comment #{comment.id} of User #{user.id} not reported" end end end + def hide_comment(comment, user, reporter_user) + Admin::HideResource.call(comment, reporter_user) do + on(:ok) do + puts "OK: Comment #{comment.id} of User #{user.id} hided" + end + + on(:invalid) do + puts "ERROR: Comment #{comment.id} of User #{user.id} not hided" + end + end + end + def context_for_report(user, comment, reporter_user) { current_organization: user.organization, current_component: comment.component, current_user: reporter_user, current_participatory_space: comment.participatory_space } end end + # rubocop:enable Metrics/ClassLength end end end