Class: Decidim::Admin::DeliverNewsletter
- Inherits:
-
Command
- Object
- Command
- Decidim::Admin::DeliverNewsletter
- Defined in:
- app/commands/decidim/admin/deliver_newsletter.rb
Overview
Delivers the newsletter to its recipients.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(newsletter, form) ⇒ DeliverNewsletter
constructor
Initializes the command.
Constructor Details
#initialize(newsletter, form) ⇒ DeliverNewsletter
Initializes the command.
newsletter - The newsletter to deliver. form - A form object with the params.
12 13 14 15 |
# File 'app/commands/decidim/admin/deliver_newsletter.rb', line 12 def initialize(, form) @newsletter = @form = form end |
Instance Method Details
#call ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/commands/decidim/admin/deliver_newsletter.rb', line 17 def call return broadcast(:invalid) if @form.send_to_all_users && !current_user.admin? return broadcast(:invalid) unless @form.valid? return broadcast(:invalid) if @newsletter.sent? return broadcast(:no_recipients) if recipients.blank? @newsletter.with_lock do end broadcast(:ok, @newsletter) end |