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, user) ⇒ DeliverNewsletter
constructor
Initializes the command.
Constructor Details
#initialize(newsletter, form, user) ⇒ DeliverNewsletter
Initializes the command.
newsletter - The newsletter to deliver. form - A form object with the params. user - the Decidim::User that delivers the newsletter
12 13 14 15 16 |
# File 'app/commands/decidim/admin/deliver_newsletter.rb', line 12 def initialize(, form, user) @newsletter = @form = form @user = user end |
Instance Method Details
#call ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/commands/decidim/admin/deliver_newsletter.rb', line 18 def call return broadcast(:invalid) if @form.send_to_all_users && !@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 |