remove trailing white-spaces from mailer model source.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5816 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
f2e5b62448
commit
01c5311662
|
@ -31,7 +31,7 @@ class Mailer < ActionMailer::Base
|
||||||
h = h.to_s.gsub(%r{\/.*$}, '') unless Redmine::Utils.relative_url_root.blank?
|
h = h.to_s.gsub(%r{\/.*$}, '') unless Redmine::Utils.relative_url_root.blank?
|
||||||
{ :host => h, :protocol => Setting.protocol }
|
{ :host => h, :protocol => Setting.protocol }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Builds a tmail object used to email recipients of the added issue.
|
# Builds a tmail object used to email recipients of the added issue.
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
|
@ -133,7 +133,7 @@ class Mailer < ActionMailer::Base
|
||||||
:added_to_url => added_to_url
|
:added_to_url => added_to_url
|
||||||
render_multipart('attachments_added', body)
|
render_multipart('attachments_added', body)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Builds a tmail object used to email recipients of a news' project when a news item is added.
|
# Builds a tmail object used to email recipients of a news' project when a news item is added.
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
|
@ -148,7 +148,7 @@ class Mailer < ActionMailer::Base
|
||||||
:news_url => url_for(:controller => 'news', :action => 'show', :id => news)
|
:news_url => url_for(:controller => 'news', :action => 'show', :id => news)
|
||||||
render_multipart('news_added', body)
|
render_multipart('news_added', body)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Builds a tmail object used to email recipients of a news' project when a news comment is added.
|
# Builds a tmail object used to email recipients of a news' project when a news comment is added.
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
|
@ -167,7 +167,7 @@ class Mailer < ActionMailer::Base
|
||||||
render_multipart('news_comment_added', body)
|
render_multipart('news_comment_added', body)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Builds a tmail object used to email the recipients of the specified message that was posted.
|
# Builds a tmail object used to email the recipients of the specified message that was posted.
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
# message_posted(message) => tmail object
|
# message_posted(message) => tmail object
|
||||||
|
@ -184,8 +184,8 @@ class Mailer < ActionMailer::Base
|
||||||
:message_url => url_for(message.event_url)
|
:message_url => url_for(message.event_url)
|
||||||
render_multipart('message_posted', body)
|
render_multipart('message_posted', body)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Builds a tmail object used to email the recipients of a project of the specified wiki content was added.
|
# Builds a tmail object used to email the recipients of a project of the specified wiki content was added.
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
# wiki_content_added(wiki_content) => tmail object
|
# wiki_content_added(wiki_content) => tmail object
|
||||||
|
@ -201,8 +201,8 @@ class Mailer < ActionMailer::Base
|
||||||
:wiki_content_url => url_for(:controller => 'wiki', :action => 'show', :project_id => wiki_content.project, :id => wiki_content.page.title)
|
:wiki_content_url => url_for(:controller => 'wiki', :action => 'show', :project_id => wiki_content.project, :id => wiki_content.page.title)
|
||||||
render_multipart('wiki_content_added', body)
|
render_multipart('wiki_content_added', body)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Builds a tmail object used to email the recipients of a project of the specified wiki content was updated.
|
# Builds a tmail object used to email the recipients of a project of the specified wiki content was updated.
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
# wiki_content_updated(wiki_content) => tmail object
|
# wiki_content_updated(wiki_content) => tmail object
|
||||||
|
@ -296,7 +296,7 @@ class Mailer < ActionMailer::Base
|
||||||
return false if (recipients.nil? || recipients.empty?) &&
|
return false if (recipients.nil? || recipients.empty?) &&
|
||||||
(cc.nil? || cc.empty?) &&
|
(cc.nil? || cc.empty?) &&
|
||||||
(bcc.nil? || bcc.empty?)
|
(bcc.nil? || bcc.empty?)
|
||||||
|
|
||||||
# Set Message-Id and References
|
# Set Message-Id and References
|
||||||
if @message_id_object
|
if @message_id_object
|
||||||
mail.message_id = self.class.message_id_for(@message_id_object)
|
mail.message_id = self.class.message_id_for(@message_id_object)
|
||||||
|
@ -304,7 +304,7 @@ class Mailer < ActionMailer::Base
|
||||||
if @references_objects
|
if @references_objects
|
||||||
mail.references = @references_objects.collect {|o| self.class.message_id_for(o)}
|
mail.references = @references_objects.collect {|o| self.class.message_id_for(o)}
|
||||||
end
|
end
|
||||||
|
|
||||||
# Log errors when raise_delivery_errors is set to false, Rails does not
|
# Log errors when raise_delivery_errors is set to false, Rails does not
|
||||||
raise_errors = self.class.raise_delivery_errors
|
raise_errors = self.class.raise_delivery_errors
|
||||||
self.class.raise_delivery_errors = true
|
self.class.raise_delivery_errors = true
|
||||||
|
@ -347,7 +347,7 @@ class Mailer < ActionMailer::Base
|
||||||
deliver_reminder(assignee, issues, days) if assignee && assignee.active?
|
deliver_reminder(assignee, issues, days) if assignee && assignee.active?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Activates/desactivates email deliveries during +block+
|
# Activates/desactivates email deliveries during +block+
|
||||||
def self.with_deliveries(enabled = true, &block)
|
def self.with_deliveries(enabled = true, &block)
|
||||||
was_enabled = ActionMailer::Base.perform_deliveries
|
was_enabled = ActionMailer::Base.perform_deliveries
|
||||||
|
@ -363,7 +363,7 @@ class Mailer < ActionMailer::Base
|
||||||
@initial_language = current_language
|
@initial_language = current_language
|
||||||
set_language_if_valid Setting.default_language
|
set_language_if_valid Setting.default_language
|
||||||
from Setting.mail_from
|
from Setting.mail_from
|
||||||
|
|
||||||
# Common headers
|
# Common headers
|
||||||
headers 'X-Mailer' => 'Redmine',
|
headers 'X-Mailer' => 'Redmine',
|
||||||
'X-Redmine-Host' => Setting.host_name,
|
'X-Redmine-Host' => Setting.host_name,
|
||||||
|
@ -386,11 +386,11 @@ class Mailer < ActionMailer::Base
|
||||||
recipients.delete(@author.mail) if recipients
|
recipients.delete(@author.mail) if recipients
|
||||||
cc.delete(@author.mail) if cc
|
cc.delete(@author.mail) if cc
|
||||||
end
|
end
|
||||||
|
|
||||||
notified_users = [recipients, cc].flatten.compact.uniq
|
notified_users = [recipients, cc].flatten.compact.uniq
|
||||||
# Rails would log recipients only, not cc and bcc
|
# Rails would log recipients only, not cc and bcc
|
||||||
mylogger.info "Sending email notification to: #{notified_users.join(', ')}" if mylogger
|
mylogger.info "Sending email notification to: #{notified_users.join(', ')}" if mylogger
|
||||||
|
|
||||||
# Blind carbon copy recipients
|
# Blind carbon copy recipients
|
||||||
if Setting.bcc_recipients?
|
if Setting.bcc_recipients?
|
||||||
bcc(notified_users)
|
bcc(notified_users)
|
||||||
|
@ -406,7 +406,7 @@ class Mailer < ActionMailer::Base
|
||||||
#
|
#
|
||||||
# https://rails.lighthouseapp.com/projects/8994/tickets/2338-actionmailer-mailer-views-and-content-type
|
# https://rails.lighthouseapp.com/projects/8994/tickets/2338-actionmailer-mailer-views-and-content-type
|
||||||
# https://rails.lighthouseapp.com/projects/8994/tickets/1799-actionmailer-doesnt-set-template_format-when-rendering-layouts
|
# https://rails.lighthouseapp.com/projects/8994/tickets/1799-actionmailer-doesnt-set-template_format-when-rendering-layouts
|
||||||
|
|
||||||
def render_multipart(method_name, body)
|
def render_multipart(method_name, body)
|
||||||
if Setting.plain_text_mail?
|
if Setting.plain_text_mail?
|
||||||
content_type "text/plain"
|
content_type "text/plain"
|
||||||
|
@ -422,29 +422,29 @@ class Mailer < ActionMailer::Base
|
||||||
def self.controller_path
|
def self.controller_path
|
||||||
''
|
''
|
||||||
end unless respond_to?('controller_path')
|
end unless respond_to?('controller_path')
|
||||||
|
|
||||||
# Returns a predictable Message-Id for the given object
|
# Returns a predictable Message-Id for the given object
|
||||||
def self.message_id_for(object)
|
def self.message_id_for(object)
|
||||||
# id + timestamp should reduce the odds of a collision
|
# id + timestamp should reduce the odds of a collision
|
||||||
# as far as we don't send multiple emails for the same object
|
# as far as we don't send multiple emails for the same object
|
||||||
timestamp = object.send(object.respond_to?(:created_on) ? :created_on : :updated_on)
|
timestamp = object.send(object.respond_to?(:created_on) ? :created_on : :updated_on)
|
||||||
hash = "redmine.#{object.class.name.demodulize.underscore}-#{object.id}.#{timestamp.strftime("%Y%m%d%H%M%S")}"
|
hash = "redmine.#{object.class.name.demodulize.underscore}-#{object.id}.#{timestamp.strftime("%Y%m%d%H%M%S")}"
|
||||||
host = Setting.mail_from.to_s.gsub(%r{^.*@}, '')
|
host = Setting.mail_from.to_s.gsub(%r{^.*@}, '')
|
||||||
host = "#{::Socket.gethostname}.redmine" if host.empty?
|
host = "#{::Socket.gethostname}.redmine" if host.empty?
|
||||||
"<#{hash}@#{host}>"
|
"<#{hash}@#{host}>"
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def message_id(object)
|
def message_id(object)
|
||||||
@message_id_object = object
|
@message_id_object = object
|
||||||
end
|
end
|
||||||
|
|
||||||
def references(object)
|
def references(object)
|
||||||
@references_objects ||= []
|
@references_objects ||= []
|
||||||
@references_objects << object
|
@references_objects << object
|
||||||
end
|
end
|
||||||
|
|
||||||
def mylogger
|
def mylogger
|
||||||
RAILS_DEFAULT_LOGGER
|
RAILS_DEFAULT_LOGGER
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue