Class: Decidim::Meetings::Admin::InviteUserToJoinMeeting

Inherits:
Command
  • Object
show all
Defined in:
app/commands/decidim/meetings/admin/invite_user_to_join_meeting.rb

Overview

A command with all the business logic to invite users to join a meeting.

Instance Method Summary collapse

Constructor Details

#initialize(form, meeting, invited_by) ⇒ InviteUserToJoinMeeting

Public: Initializes the command.

form - A form object with the params. meeting - The meeting which the user is invited to. invited_by - The user performing the operation



14
15
16
17
18
# File 'app/commands/decidim/meetings/admin/invite_user_to_join_meeting.rb', line 14

def initialize(form, meeting, invited_by)
  @form = form
  @meeting = meeting
  @invited_by = invited_by
end

Instance Method Details

#callObject

Executes the command. Broadcasts these events:

  • :ok when everything is valid.

  • :invalid if the form was not valid and we could not proceed.

Returns nothing.



26
27
28
29
30
31
32
# File 'app/commands/decidim/meetings/admin/invite_user_to_join_meeting.rb', line 26

def call
  return broadcast(:invalid) if form.invalid? || already_invited?

  invite_user

  broadcast(:ok)
end