Class: Decidim::Meetings::JoinMeeting

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

Overview

This command is executed when the user joins a meeting.

Instance Method Summary collapse

Constructor Details

#initialize(meeting, form) ⇒ JoinMeeting

Initializes a JoinMeeting Command.

meeting - The current instance of the meeting to be joined. form - A form object with params; can be a questionnaire.



12
13
14
15
# File 'app/commands/decidim/meetings/join_meeting.rb', line 12

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

Instance Method Details

#callObject

Creates a meeting registration if the meeting has registrations enabled and there are available slots.

Broadcasts :ok if successful, :invalid otherwise.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/commands/decidim/meetings/join_meeting.rb', line 21

def call
  return broadcast(:invalid) unless can_join_meeting?
  return broadcast(:invalid_form) unless form.valid?
  return broadcast(:invalid) if response_questionnaire == :invalid

  meeting.with_lock do
    create_registration
    accept_invitation
    send_email_confirmation
    send_notification_confirmation
    notify_admin_over_percentage
    increment_score
  end
  follow_meeting
  broadcast(:ok)
end