Class: Bible270::NoticeMailer
- Inherits:
-
ApplicationMailer
- Object
- ActionMailer::Base
- ApplicationMailer
- Bible270::NoticeMailer
- Defined in:
- app/mailers/bible270/notice_mailer.rb
Overview
Notices to whoever runs the plan, as opposed to mail sent to readers.
Instance Method Summary collapse
Instance Method Details
#mentioned(comment_id:, reader_id:) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/mailers/bible270/notice_mailer.rb', line 21 def mentioned(comment_id:, reader_id:) @comment = Comment.find_by(id: comment_id) @reader = Reader.find_by(id: reader_id) return .perform_deliveries = false if @comment.nil? || @reader.nil? || @reader.email.blank? @author = @comment.reader @app_name = Bible270.config.app_name @day_url = day_url_for(@comment.day) mail to: @reader.email, subject: "#{@app_name}: #{@author.display_name} mentioned you on day #{@comment.day}" end |
#new_reader(reader_id:, recipients:) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/mailers/bible270/notice_mailer.rb', line 6 def new_reader(reader_id:, recipients:) @reader = Reader.find_by(id: reader_id) # Blanks dropped rather than trusting the caller: [''] is not blank — a # one-element array never is — so it would otherwise have been sent to an # empty address, which fails at the SMTP server rather than here. addresses = Array(recipients).map { |address| address.to_s.strip }.reject(&:empty?) return .perform_deliveries = false if @reader.nil? || addresses.empty? @app_name = Bible270.config.app_name @total = Reader.count @admin_url = admin_url_for(@reader) mail to: addresses, subject: "#{@app_name}: #{@reader.display_name} has joined" end |