Sha256: 85240d2e2e51aede8ce75bbd0973859f2e2f09cb04f7df5907057e85c2a27b13
Contents?: true
Size: 1.12 KB
Versions: 15
Compression:
Stored size: 1.12 KB
Contents
# frozen_string_literal: true module Decidim module Admin # A command with all the business logic when a user hides a resource. class HideResource < Decidim::Command # Public: Initializes the command. # # reportable - A Decidim::Reportable # current_user - the user that performs the action def initialize(reportable, current_user) @reportable = reportable @current_user = current_user end # Executes the command. Broadcasts these events: # # - :ok when everything is valid, together with the resource. # - :invalid if the resource is already hidden # # Returns nothing. def call return broadcast(:invalid) unless hideable? with_events do tool = Decidim::ModerationTools.new(@reportable, @current_user) tool.hide! tool.send_notification_to_author end broadcast(:ok, @reportable) end private def event_arguments { resource: @reportable } end def hideable? !@reportable.hidden? && @reportable.reported? end end end end
Version data entries
15 entries across 15 versions & 1 rubygems