Sha256: 83a66bd0f5580a4b3ac6d5476cd0b8b18e931250e32b49cd4b862d83e7d47e0c

Contents?: true

Size: 1.12 KB

Versions: 25

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

module Decidim
  module Initiatives
    # A command with all the business logic that creates a new initiative.
    class ApproveMembershipRequest < Rectify::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.accepted!
        notify_applicant

        broadcast(:ok, @membership_request)
      end

      private

      def notify_applicant
        Decidim::EventsManager.publish(
          event: "decidim.events.initiatives.approve_membership_request",
          event_class: Decidim::Initiatives::ApproveMembershipRequestEvent,
          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

25 entries across 25 versions & 1 rubygems

Version Path
decidim-initiatives-0.26.10 app/commands/decidim/initiatives/approve_membership_request.rb
decidim-initiatives-0.26.9 app/commands/decidim/initiatives/approve_membership_request.rb
decidim-initiatives-0.26.8 app/commands/decidim/initiatives/approve_membership_request.rb
decidim-initiatives-0.26.7 app/commands/decidim/initiatives/approve_membership_request.rb
decidim-initiatives-0.26.5 app/commands/decidim/initiatives/approve_membership_request.rb
decidim-initiatives-0.26.4 app/commands/decidim/initiatives/approve_membership_request.rb
decidim-initiatives-0.26.3 app/commands/decidim/initiatives/approve_membership_request.rb
decidim-initiatives-0.26.2 app/commands/decidim/initiatives/approve_membership_request.rb
decidim-initiatives-0.26.1 app/commands/decidim/initiatives/approve_membership_request.rb
decidim-initiatives-0.26.0 app/commands/decidim/initiatives/approve_membership_request.rb
decidim-initiatives-0.26.0.rc2 app/commands/decidim/initiatives/approve_membership_request.rb
decidim-initiatives-0.26.0.rc1 app/commands/decidim/initiatives/approve_membership_request.rb
decidim-initiatives-0.25.2 app/commands/decidim/initiatives/approve_membership_request.rb
decidim-initiatives-0.25.1 app/commands/decidim/initiatives/approve_membership_request.rb
decidim-initiatives-0.25.0 app/commands/decidim/initiatives/approve_membership_request.rb
decidim-initiatives-0.25.0.rc4 app/commands/decidim/initiatives/approve_membership_request.rb
decidim-initiatives-0.25.0.rc3 app/commands/decidim/initiatives/approve_membership_request.rb
decidim-initiatives-0.25.0.rc2 app/commands/decidim/initiatives/approve_membership_request.rb
decidim-initiatives-0.25.0.rc1 app/commands/decidim/initiatives/approve_membership_request.rb
decidim-initiatives-0.24.3 app/commands/decidim/initiatives/approve_membership_request.rb