Sha256: 4fe66a4dd5b65005ff141f45cc05d3b42421d033d2b367deebe9aeb074169eb5
Contents?: true
Size: 860 Bytes
Versions: 54
Compression:
Stored size: 860 Bytes
Contents
# frozen_string_literal: true module Decidim module Admin # A command with all the business logic when a user unreports a resource. class UnreportResource < Rectify::Command # Public: Initializes the command. # # reportable - A Decidim::Reportable def initialize(reportable) @reportable = reportable end # Executes the command. Broadcasts these events: # # - :ok when everything is valid, together with the resource. # - :invalid if the resource is not reported # # Returns nothing. def call return broadcast(:invalid) unless @reportable.reported? unreport! broadcast(:ok, @reportable) end private def unreport! @reportable.moderation.update_attributes!(report_count: 0, hidden_at: nil) end end end end
Version data entries
54 entries across 54 versions & 2 rubygems