Sha256: 353efabc390aff1d5981497b5bdb295e3612d310a9239362566f0a407b1170fa
Contents?: true
Size: 970 Bytes
Versions: 13
Compression:
Stored size: 970 Bytes
Contents
# frozen_string_literal: true module Decidim # A command with all the business logic to reject an invitation to belong to a # group. class RejectGroupInvitation < Decidim::Command # Public: Initializes the command. # # user_group - the UserGroup where the user has been invited # user - the User that has been invited def initialize(user_group, user) @user_group = user_group @user = user end # Executes the command. Broadcasts these events: # # - :ok when everything is valid. # - :invalid if we could not proceed. # # Returns nothing. def call return broadcast(:invalid) if membership.blank? reject_invitation broadcast(:ok) end private attr_reader :user_group, :user def reject_invitation membership.destroy! end def membership @membership ||= Decidim::UserGroupMembership.find_by(user:, user_group:, role: :invited) end end end
Version data entries
13 entries across 13 versions & 1 rubygems