Sha256: b131d1770216ff754ed769523409ccdad94b8fcd261e5db6043e1bddb9820109

Contents?: true

Size: 1.11 KB

Versions: 23

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

module Decidim
  module Initiatives
    # A command with all the business logic that creates a new initiative.
    class RevokeMembershipRequest < Decidim::Command
      # Public: Initializes the command.
      #
      # membership_request - A pending committee member
      def initialize(membership_request)
        @membership_request = membership_request
      end

      # Executes the command. Broadcasts these events:
      #
      # - :ok when everything is valid.
      #
      # Returns nothing.
      def call
        @membership_request.rejected!
        notify_applicant

        broadcast(:ok, @membership_request)
      end

      private

      def notify_applicant
        Decidim::EventsManager.publish(
          event: "decidim.events.initiatives.revoke_membership_request",
          event_class: Decidim::Initiatives::RevokeMembershipRequestEvent,
          resource: @membership_request.initiative,
          affected_users: [@membership_request.user],
          force_send: true,
          extra: { author: @membership_request.initiative.author }
        )
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
decidim-initiatives-0.27.9 app/commands/decidim/initiatives/revoke_membership_request.rb
decidim-initiatives-0.29.0 app/commands/decidim/initiatives/revoke_membership_request.rb
decidim-initiatives-0.28.3 app/commands/decidim/initiatives/revoke_membership_request.rb
decidim-initiatives-0.27.8 app/commands/decidim/initiatives/revoke_membership_request.rb
decidim-initiatives-0.29.0.rc4 app/commands/decidim/initiatives/revoke_membership_request.rb
decidim-initiatives-0.29.0.rc3 app/commands/decidim/initiatives/revoke_membership_request.rb
decidim-initiatives-0.29.0.rc2 app/commands/decidim/initiatives/revoke_membership_request.rb
decidim-initiatives-0.29.0.rc1 app/commands/decidim/initiatives/revoke_membership_request.rb
decidim-initiatives-0.28.2 app/commands/decidim/initiatives/revoke_membership_request.rb
decidim-initiatives-0.27.7 app/commands/decidim/initiatives/revoke_membership_request.rb
decidim-initiatives-0.28.1 app/commands/decidim/initiatives/revoke_membership_request.rb
decidim-initiatives-0.27.6 app/commands/decidim/initiatives/revoke_membership_request.rb
decidim-initiatives-0.28.0 app/commands/decidim/initiatives/revoke_membership_request.rb
decidim-initiatives-0.27.5 app/commands/decidim/initiatives/revoke_membership_request.rb
decidim-initiatives-0.28.0.rc5 app/commands/decidim/initiatives/revoke_membership_request.rb
decidim-initiatives-0.28.0.rc4 app/commands/decidim/initiatives/revoke_membership_request.rb
decidim-initiatives-0.27.4 app/commands/decidim/initiatives/revoke_membership_request.rb
decidim-initiatives-0.27.3 app/commands/decidim/initiatives/revoke_membership_request.rb
decidim-initiatives-0.27.2 app/commands/decidim/initiatives/revoke_membership_request.rb
decidim-initiatives-0.27.1 app/commands/decidim/initiatives/revoke_membership_request.rb