Class: Decidim::Meetings::JoinWaitlist

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

Overview

This command is executed when the user joins a meeting waitlist.

Instance Method Summary collapse

Constructor Details

#initialize(meeting, form) ⇒ JoinWaitlist

Returns a new instance of JoinWaitlist.



9
10
11
12
# File 'app/commands/decidim/meetings/join_waitlist.rb', line 9

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

Instance Method Details

#callObject



14
15
16
17
18
19
20
21
22
23
24
# File 'app/commands/decidim/meetings/join_waitlist.rb', line 14

def call
  return broadcast(:invalid) unless can_join_waitlist?
  return broadcast(:invalid_form) unless form.valid?

  meeting.with_lock do
    create_waitlist_entry
    send_waitlist_notification
  end

  broadcast(:ok)
end