notification_mailer.rb
上传用户:netsea168
上传日期:2022-07-22
资源大小:4652k
文件大小:1k
源码类别:

Ajax

开发平台:

Others

  1. class NotificationMailer < ActionMailer::Base
  2.   helper :mail
  3.   
  4.   def article(article, user)
  5.     setup(user, article)
  6.     @subject        = "[#{article.blog.blog_name}] New article: #{article.title}"
  7.     @body[:article] = article
  8.   end
  9.   def comment(comment, user)
  10.     setup(user, comment)
  11.     @subject        = "[#{comment.blog.blog_name}] New comment on #{comment.article.title}"
  12.     @body[:article] = comment.article
  13.     @body[:comment] = comment
  14.   end
  15.   def trackback(sent_at = Time.now)
  16.     setup(user, trackback)
  17.     @subject          = "[#{trackback.blog.blog_name}] New trackback on #{trackback.article.title}"
  18.     @body[:article]   = trackback.article
  19.     @body[:trackback] = trackback
  20.   end
  21.   def notif_user(user)
  22.     @body[:user] = user
  23.     @body[:blog] = Blog.default
  24.     @recipients  = user.email
  25.     @from        = Blog.default.email_from
  26.     @headers     = {'X-Mailer' => "Typo #{TYPO_VERSION}"}
  27.   end
  28.   private
  29.   def setup(user, content)
  30.     @body[:user] = user
  31.     @body[:blog] = content.blog
  32.     @recipients  = user.email
  33.     @from        = content.blog.email_from
  34.     @headers     = {'X-Mailer' => "Typo #{TYPO_VERSION}"}
  35.   end
  36. end