Sha256: feeab4e079b3a928631214c930b1130dbfbc71c20830e19d15671e00e94489ca

Contents?: true

Size: 1.5 KB

Versions: 3

Compression:

Stored size: 1.5 KB

Contents

module Commontator
  class SubscriptionsMailer < ActionMailer::Base
    include SharedHelper
    include ThreadsHelper
  
    def comment_created(comment, recipients)
      setup_variables(comment, recipients)

      mail :to => 'Undisclosed Recipients',
           :bcc => @bcc,
           :from => @from,
           :subject => @subject
    end

    protected

    def setup_variables(comment, recipients)
      @comment = comment
      @thread = @comment.thread
      @creator = @comment.creator
      
      @commontable = @thread.commontable
      @config = @thread.config
      
      @creator_name = commontator_name(@creator)
      @comment_timestamp = @comment.timestamp
      
      @commontable_name = commontable_name(@thread)
      @commontable_id = commontable_id(@thread).to_s
      
      @commontable_url = ApplicationController.commontable_url
      
      params = Hash.new
      params[:comment] = @comment
      params[:thread] = @thread
      params[:creator] = @creator
      params[:commontable] = @commontable
      params[:config] = @config
      params[:creator_name] = @creator_name
      params[:comment_timestamp] = @comment_timestamp
      params[:commontable_name] = @commontable_name
      params[:commontable_id] = @commontable_id
      params[:commontable_url] = @commontable_url
      
      @bcc = recipients.collect{|s| commontator_email(s)}
      @from = @config.subscription_email_from_proc.call(params)
      @subject = @config.subscription_email_subject_proc.call(params)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
commontator-4.0.2 app/mailers/commontator/subscriptions_mailer.rb
commontator-4.0.1 app/mailers/commontator/subscriptions_mailer.rb
commontator-4.0.0 app/mailers/commontator/subscriptions_mailer.rb