Sha256: 2dfd6d143dff86328989db251da6d407e7e202e1b3336136da1a20714739f65e

Contents?: true

Size: 1.52 KB

Versions: 2

Compression:

Stored size: 1.52 KB

Contents

module Commontator
  class SubscriptionsMailer < ActionMailer::Base
    include CommentsHelper
    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
      @commontator = @comment.commontator
      
      @bcc = @thread.subscribers.reject{|s| s == @commontator}\
                                .collect{|s| email(s)}
      
      return if @bcc.empty?
      
      @commontable = @thread.commontable
      @config = @thread.config
      
      @commontator_name = commontator_name(@comment)
      @comment_timestamp = comment_timestamp(@comment)
      
      @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[:commontator] = @commontator
      params[:commontable] = @commontable
      params[:config] = @config
      params[:commontator_name] = @commontator_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

2 entries across 2 versions & 1 rubygems

Version Path
commontator-0.4.1 app/mailers/commontator/subscriptions_mailer.rb
commontator-0.3.10 app/mailers/commontator/subscriptions_mailer.rb