Sha256: 9760824ddf93893227a8be4526098f1c5d0d32f498b8a41c47fb0de7cb3d47c0

Contents?: true

Size: 1.58 KB

Versions: 7

Compression:

Stored size: 1.58 KB

Contents

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

      mail(:bcc => @bcc, :subject => @subject) \
        unless @bcc.empty?
    end

protected

    def setup_variables(comment, commontable_url)
      
      @comment = comment
      @thread = @comment.thread
      @creator = @comment.creator
      
      @bcc = @thread.subscribers.reject{|s| !s.commontator_config.subscription_emails || \
                                            s == @creator} \
                                .collect{|s| commontator_email(s)}
      
      return if @bcc.empty?
      
      @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 = 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
      
      @subject = @config.subscription_email_subject_proc.call(params)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
commontator-1.0.6 app/mailers/commontator/subscriptions_mailer.rb
commontator-1.0.5 app/mailers/commontator/subscriptions_mailer.rb
commontator-1.0.4 app/mailers/commontator/subscriptions_mailer.rb
commontator-1.0.3 app/mailers/commontator/subscriptions_mailer.rb
commontator-1.0.2 app/mailers/commontator/subscriptions_mailer.rb
commontator-1.0.1 app/mailers/commontator/subscriptions_mailer.rb
commontator-1.0.0 app/mailers/commontator/subscriptions_mailer.rb