除了mail_notification == all 的,其他都不即时发邮件
This commit is contained in:
parent
3ea33aa847
commit
243bac8fed
|
@ -165,7 +165,9 @@ class Mailer < ActionMailer::Base
|
||||||
# cc = wiki_content.page.wiki.watcher_recipients - recipients
|
# cc = wiki_content.page.wiki.watcher_recipients - recipients
|
||||||
|
|
||||||
@memo_url = url_for(forum_memo_url(@forum, (@memo.parent_id.nil? ? @memo : @memo.parent_id)))
|
@memo_url = url_for(forum_memo_url(@forum, (@memo.parent_id.nil? ? @memo : @memo.parent_id)))
|
||||||
mail :to => recipients,:subject => "[ #{l(:label_message_plural)} : #{memo.subject} #{l(:label_memo_create_succ)}]"
|
mail :to => recipients,
|
||||||
|
:subject => "[ #{l(:label_message_plural)} : #{memo.subject} #{l(:label_memo_create_succ)}]",
|
||||||
|
:filter => true
|
||||||
end
|
end
|
||||||
# Builds a Mail::Message object used to email recipients of the added journals for message.
|
# Builds a Mail::Message object used to email recipients of the added journals for message.
|
||||||
|
|
||||||
|
@ -222,20 +224,21 @@ class Mailer < ActionMailer::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
mail :to => @recipients,
|
mail :to => @recipients,
|
||||||
:subject => "#{l(:label_your_course)}#{journals_for_message.jour.name}#{l(:label_have_message)} "
|
:subject => "#{l(:label_your_course)}#{journals_for_message.jour.name}#{l(:label_have_message)} ",
|
||||||
|
:filter => true
|
||||||
elsif journals_for_message.jour.class.to_s.to_sym == :Bid
|
elsif journals_for_message.jour.class.to_s.to_sym == :Bid
|
||||||
if !journals_for_message.jour.author.notify_about? journals_for_message
|
if !journals_for_message.jour.author.notify_about? journals_for_message
|
||||||
return -1
|
return -1
|
||||||
end
|
end
|
||||||
|
|
||||||
mail :to => recipients, :subject => @title
|
mail :to => recipients, :subject => @title,:filter => true
|
||||||
elsif journals_for_message.jour.class.to_s.to_sym == :Contest
|
elsif journals_for_message.jour.class.to_s.to_sym == :Contest
|
||||||
if !journals_for_message.jour.author.notify_about? journals_for_message
|
if !journals_for_message.jour.author.notify_about? journals_for_message
|
||||||
return -1
|
return -1
|
||||||
end
|
end
|
||||||
mail :to => recipients, :subject => @title
|
mail :to => recipients, :subject => @title,:filter => true
|
||||||
else
|
else
|
||||||
mail :to => recipients1, :subject => @title
|
mail :to => recipients1, :subject => @title,:filter => true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -270,9 +273,9 @@ class Mailer < ActionMailer::Base
|
||||||
|
|
||||||
|
|
||||||
subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}"
|
subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}"
|
||||||
mail(:to => recipients,
|
mail :to => recipients,
|
||||||
|
:subject => subject,
|
||||||
:subject => subject)
|
:filter => true
|
||||||
end
|
end
|
||||||
# issue.attachments.each do |attach|
|
# issue.attachments.each do |attach|
|
||||||
# attachments["#{attach.filename}"] = File.read("#{attach.disk_filename}")
|
# attachments["#{attach.filename}"] = File.read("#{attach.disk_filename}")
|
||||||
|
@ -318,9 +321,9 @@ class Mailer < ActionMailer::Base
|
||||||
@issue = issue
|
@issue = issue
|
||||||
@journal = journal
|
@journal = journal
|
||||||
# @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue, :anchor => "change-#{journal.id}")
|
# @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue, :anchor => "change-#{journal.id}")
|
||||||
mail(:to => recipients,
|
mail :to => recipients,
|
||||||
|
:subject => s,
|
||||||
:subject => s)
|
:filter => true
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.deliver_mailer(to,cc, subject)
|
def self.deliver_mailer(to,cc, subject)
|
||||||
|
@ -406,7 +409,8 @@ class Mailer < ActionMailer::Base
|
||||||
@issue_author_url = url_for(user_activities_url(@author))
|
@issue_author_url = url_for(user_activities_url(@author))
|
||||||
@document_url = url_for(:controller => 'documents', :action => 'show', :id => document)
|
@document_url = url_for(:controller => 'documents', :action => 'show', :id => document)
|
||||||
mail :to => document.recipients,
|
mail :to => document.recipients,
|
||||||
:subject => "[#{document.project.name}] #{l(:label_document_new)}: #{document.title}"
|
:subject => "[#{document.project.name}] #{l(:label_document_new)}: #{document.title}",
|
||||||
|
:filter => true
|
||||||
end
|
end
|
||||||
|
|
||||||
# Builds a Mail::Message object used to email recipients of a project when an attachements are added.
|
# Builds a Mail::Message object used to email recipients of a project when an attachements are added.
|
||||||
|
@ -444,21 +448,24 @@ class Mailer < ActionMailer::Base
|
||||||
@added_to = added_to
|
@added_to = added_to
|
||||||
@added_to_url = added_to_url
|
@added_to_url = added_to_url
|
||||||
mail :to => recipients,
|
mail :to => recipients,
|
||||||
:subject => "[#{container.name}] #{l(:label_attachment_new)}"
|
:subject => "[#{container.name}] #{l(:label_attachment_new)}",
|
||||||
|
:filter => true
|
||||||
elsif container.class.name == 'Project'
|
elsif container.class.name == 'Project'
|
||||||
redmine_headers 'Project' => container.id
|
redmine_headers 'Project' => container.id
|
||||||
@attachments = attachments
|
@attachments = attachments
|
||||||
@added_to = added_to
|
@added_to = added_to
|
||||||
@added_to_url = added_to_url
|
@added_to_url = added_to_url
|
||||||
mail :to => recipients,
|
mail :to => recipients,
|
||||||
:subject => "[#{container.name}] #{l(:label_attachment_new)}"
|
:subject => "[#{container.name}] #{l(:label_attachment_new)}",
|
||||||
|
:filter => true
|
||||||
else
|
else
|
||||||
redmine_headers 'Project' => container.project.identifier
|
redmine_headers 'Project' => container.project.identifier
|
||||||
@attachments = attachments
|
@attachments = attachments
|
||||||
@added_to = added_to
|
@added_to = added_to
|
||||||
@added_to_url = added_to_url
|
@added_to_url = added_to_url
|
||||||
mail :to => recipients,
|
mail :to => recipients,
|
||||||
:subject => "[#{container.project.name}] #{l(:label_attachment_new)}"
|
:subject => "[#{container.project.name}] #{l(:label_attachment_new)}",
|
||||||
|
:filter => true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -477,7 +484,8 @@ class Mailer < ActionMailer::Base
|
||||||
@news = news
|
@news = news
|
||||||
@news_url = url_for(:controller => 'news', :action => 'show', :id => news)
|
@news_url = url_for(:controller => 'news', :action => 'show', :id => news)
|
||||||
mail :to => news.recipients,
|
mail :to => news.recipients,
|
||||||
:subject => "[#{news.project.name}] #{l(:label_news)}: #{news.title}"
|
:subject => "[#{news.project.name}] #{l(:label_news)}: #{news.title}",
|
||||||
|
:filter => true
|
||||||
elsif news.course
|
elsif news.course
|
||||||
redmine_headers 'Course' => news.course.id
|
redmine_headers 'Course' => news.course.id
|
||||||
@author = news.author
|
@author = news.author
|
||||||
|
@ -487,7 +495,8 @@ class Mailer < ActionMailer::Base
|
||||||
recipients = news.course.notified_users.select { |user| user.allowed_to?(:view_files, news.course) }.collect { |u| u.mail }
|
recipients = news.course.notified_users.select { |user| user.allowed_to?(:view_files, news.course) }.collect { |u| u.mail }
|
||||||
@news_url = url_for(:controller => 'news', :action => 'show', :id => news)
|
@news_url = url_for(:controller => 'news', :action => 'show', :id => news)
|
||||||
mail :to => recipients,
|
mail :to => recipients,
|
||||||
:subject => "[#{news.course.name}] #{l(:label_news)}: #{news.title}"
|
:subject => "[#{news.course.name}] #{l(:label_news)}: #{news.title}",
|
||||||
|
:filter => true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -508,7 +517,8 @@ class Mailer < ActionMailer::Base
|
||||||
@news_url = url_for(:controller => 'news', :action => 'show', :id => news)
|
@news_url = url_for(:controller => 'news', :action => 'show', :id => news)
|
||||||
mail :to => news.recipients,
|
mail :to => news.recipients,
|
||||||
:cc => news.watcher_recipients,
|
:cc => news.watcher_recipients,
|
||||||
:subject => "Re: [#{news.project.name}] #{l(:label_news)}: #{news.title}"
|
:subject => "Re: [#{news.project.name}] #{l(:label_news)}: #{news.title}",
|
||||||
|
:filter => true
|
||||||
elsif news.course
|
elsif news.course
|
||||||
redmine_headers 'Course' => news.course.id
|
redmine_headers 'Course' => news.course.id
|
||||||
@author = comment.author
|
@author = comment.author
|
||||||
|
@ -520,7 +530,8 @@ class Mailer < ActionMailer::Base
|
||||||
recipients = news.course.notified_users.select { |user| user.allowed_to?(:view_files, news.course) }.collect { |u| u.mail }
|
recipients = news.course.notified_users.select { |user| user.allowed_to?(:view_files, news.course) }.collect { |u| u.mail }
|
||||||
|
|
||||||
mail :to => recipients,
|
mail :to => recipients,
|
||||||
:subject => "[#{news.course.name}] #{l(:label_news)}: #{news.title}"
|
:subject => "[#{news.course.name}] #{l(:label_news)}: #{news.title}",
|
||||||
|
:filter => true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -543,7 +554,8 @@ class Mailer < ActionMailer::Base
|
||||||
@message_url = url_for(message.event_url)
|
@message_url = url_for(message.event_url)
|
||||||
mail :to => recipients,
|
mail :to => recipients,
|
||||||
:cc => cc,
|
:cc => cc,
|
||||||
:subject => "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}"
|
:subject => "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}",
|
||||||
|
:filter => true
|
||||||
elsif message.course
|
elsif message.course
|
||||||
redmine_headers 'Course' => message.course.id,
|
redmine_headers 'Course' => message.course.id,
|
||||||
'Topic-Id' => (message.parent_id || message.id)
|
'Topic-Id' => (message.parent_id || message.id)
|
||||||
|
@ -557,7 +569,8 @@ class Mailer < ActionMailer::Base
|
||||||
@message_url = url_for(message.event_url)
|
@message_url = url_for(message.event_url)
|
||||||
mail :to => recipients,
|
mail :to => recipients,
|
||||||
:cc => cc,
|
:cc => cc,
|
||||||
:subject => "[#{message.board.course.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}"
|
:subject => "[#{message.board.course.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}",
|
||||||
|
:filter => true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -579,7 +592,8 @@ class Mailer < ActionMailer::Base
|
||||||
:id => wiki_content.page.title)
|
:id => wiki_content.page.title)
|
||||||
mail :to => recipients,
|
mail :to => recipients,
|
||||||
:cc => cc,
|
:cc => cc,
|
||||||
:subject => "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_added, :id => wiki_content.page.pretty_title)}"
|
:subject => "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_added, :id => wiki_content.page.pretty_title)}",
|
||||||
|
:filter => true
|
||||||
end
|
end
|
||||||
|
|
||||||
# Builds a Mail::Message object used to email the recipients of a project of the specified wiki content was updated.
|
# Builds a Mail::Message object used to email the recipients of a project of the specified wiki content was updated.
|
||||||
|
@ -603,7 +617,8 @@ class Mailer < ActionMailer::Base
|
||||||
:version => wiki_content.version)
|
:version => wiki_content.version)
|
||||||
mail :to => recipients,
|
mail :to => recipients,
|
||||||
:cc => cc,
|
:cc => cc,
|
||||||
:subject => "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_updated, :id => wiki_content.page.pretty_title)}"
|
:subject => "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_updated, :id => wiki_content.page.pretty_title)}",
|
||||||
|
:filter => true
|
||||||
end
|
end
|
||||||
|
|
||||||
# Builds a Mail::Message object used to email the specified user their account information.
|
# Builds a Mail::Message object used to email the specified user their account information.
|
||||||
|
@ -754,6 +769,25 @@ class Mailer < ActionMailer::Base
|
||||||
ActionMailer::Base.delivery_method = saved_method
|
ActionMailer::Base.delivery_method = saved_method
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#过滤掉不是不合规则的收件人
|
||||||
|
def filter(reps)
|
||||||
|
r_reps = []
|
||||||
|
if reps.is_a? Array
|
||||||
|
reps.each do |r|
|
||||||
|
u = User.find_by_mail(r)
|
||||||
|
if u && u.mail_notification == 'all'
|
||||||
|
r_reps << r
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elsif reps.is_a? User
|
||||||
|
u = User.find_by_mail(r)
|
||||||
|
if u && u.mail_notification == 'all'
|
||||||
|
r_reps << r
|
||||||
|
end
|
||||||
|
end
|
||||||
|
r_reps
|
||||||
|
end
|
||||||
|
|
||||||
def mail(headers={})
|
def mail(headers={})
|
||||||
headers.merge! 'X-Mailer' => 'Redmine',
|
headers.merge! 'X-Mailer' => 'Redmine',
|
||||||
'X-Redmine-Host' => Setting.host_name,
|
'X-Redmine-Host' => Setting.host_name,
|
||||||
|
@ -770,6 +804,11 @@ class Mailer < ActionMailer::Base
|
||||||
headers[:cc].delete(@author.mail) if headers[:cc].is_a?(Array)
|
headers[:cc].delete(@author.mail) if headers[:cc].is_a?(Array)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if headers[:filter]
|
||||||
|
headers[:to] = filter(headers[:to])
|
||||||
|
headers[:cc] = filter(headers[:cc])
|
||||||
|
end
|
||||||
|
|
||||||
if @author && @author.logged?
|
if @author && @author.logged?
|
||||||
redmine_headers 'Sender' => @author.login
|
redmine_headers 'Sender' => @author.login
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue