##// END OF EJS Templates
add roadie-rails gem for e-mail inline styles (#8335, #20641)...
Toshi MARUYAMA -
r14158:0dc3c2fe1c86
parent child
Show More
@@ -1,111 +1,112
1 source 'https://rubygems.org'
1 source 'https://rubygems.org'
2
2
3 if Gem::Version.new(Bundler::VERSION) < Gem::Version.new('1.5.0')
3 if Gem::Version.new(Bundler::VERSION) < Gem::Version.new('1.5.0')
4 abort "Redmine requires Bundler 1.5.0 or higher (you're using #{Bundler::VERSION}).\nPlease update with 'gem update bundler'."
4 abort "Redmine requires Bundler 1.5.0 or higher (you're using #{Bundler::VERSION}).\nPlease update with 'gem update bundler'."
5 end
5 end
6
6
7 gem "rails", "4.2.4"
7 gem "rails", "4.2.4"
8 gem "jquery-rails", "~> 3.1.3"
8 gem "jquery-rails", "~> 3.1.3"
9 gem "coderay", "~> 1.1.0"
9 gem "coderay", "~> 1.1.0"
10 gem "builder", ">= 3.0.4"
10 gem "builder", ">= 3.0.4"
11 gem "request_store", "1.0.5"
11 gem "request_store", "1.0.5"
12 gem "mime-types"
12 gem "mime-types"
13 gem "protected_attributes"
13 gem "protected_attributes"
14 gem "actionpack-action_caching"
14 gem "actionpack-action_caching"
15 gem "actionpack-xml_parser"
15 gem "actionpack-xml_parser"
16 gem "loofah", "~> 2.0"
16 gem "loofah", "~> 2.0"
17 gem "roadie-rails"
17
18
18 # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
19 # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
19 gem 'tzinfo-data', platforms: [:mingw, :x64_mingw, :mswin, :jruby]
20 gem 'tzinfo-data', platforms: [:mingw, :x64_mingw, :mswin, :jruby]
20 gem "rbpdf", "~> 1.18.6"
21 gem "rbpdf", "~> 1.18.6"
21
22
22 # Optional gem for LDAP authentication
23 # Optional gem for LDAP authentication
23 group :ldap do
24 group :ldap do
24 gem "net-ldap", "~> 0.3.1"
25 gem "net-ldap", "~> 0.3.1"
25 end
26 end
26
27
27 # Optional gem for OpenID authentication
28 # Optional gem for OpenID authentication
28 group :openid do
29 group :openid do
29 gem "ruby-openid", "~> 2.3.0", :require => "openid"
30 gem "ruby-openid", "~> 2.3.0", :require => "openid"
30 gem "rack-openid"
31 gem "rack-openid"
31 end
32 end
32
33
33 platforms :mri, :mingw, :x64_mingw do
34 platforms :mri, :mingw, :x64_mingw do
34 # Optional gem for exporting the gantt to a PNG file, not supported with jruby
35 # Optional gem for exporting the gantt to a PNG file, not supported with jruby
35 group :rmagick do
36 group :rmagick do
36 gem "rmagick", ">= 2.14.0"
37 gem "rmagick", ">= 2.14.0"
37 end
38 end
38
39
39 # Optional Markdown support, not for JRuby
40 # Optional Markdown support, not for JRuby
40 group :markdown do
41 group :markdown do
41 gem "redcarpet", "~> 3.3.2"
42 gem "redcarpet", "~> 3.3.2"
42 end
43 end
43 end
44 end
44
45
45 platforms :jruby do
46 platforms :jruby do
46 # jruby-openssl is bundled with JRuby 1.7.0
47 # jruby-openssl is bundled with JRuby 1.7.0
47 gem "jruby-openssl" if Object.const_defined?(:JRUBY_VERSION) && JRUBY_VERSION < '1.7.0'
48 gem "jruby-openssl" if Object.const_defined?(:JRUBY_VERSION) && JRUBY_VERSION < '1.7.0'
48 gem "activerecord-jdbc-adapter", "~> 1.3.2"
49 gem "activerecord-jdbc-adapter", "~> 1.3.2"
49 end
50 end
50
51
51 # Include database gems for the adapters found in the database
52 # Include database gems for the adapters found in the database
52 # configuration file
53 # configuration file
53 require 'erb'
54 require 'erb'
54 require 'yaml'
55 require 'yaml'
55 database_file = File.join(File.dirname(__FILE__), "config/database.yml")
56 database_file = File.join(File.dirname(__FILE__), "config/database.yml")
56 if File.exist?(database_file)
57 if File.exist?(database_file)
57 database_config = YAML::load(ERB.new(IO.read(database_file)).result)
58 database_config = YAML::load(ERB.new(IO.read(database_file)).result)
58 adapters = database_config.values.map {|c| c['adapter']}.compact.uniq
59 adapters = database_config.values.map {|c| c['adapter']}.compact.uniq
59 if adapters.any?
60 if adapters.any?
60 adapters.each do |adapter|
61 adapters.each do |adapter|
61 case adapter
62 case adapter
62 when 'mysql2'
63 when 'mysql2'
63 gem "mysql2", "~> 0.3.11", :platforms => [:mri, :mingw, :x64_mingw]
64 gem "mysql2", "~> 0.3.11", :platforms => [:mri, :mingw, :x64_mingw]
64 gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
65 gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
65 when 'mysql'
66 when 'mysql'
66 gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
67 gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
67 when /postgresql/
68 when /postgresql/
68 gem "pg", "~> 0.18.1", :platforms => [:mri, :mingw, :x64_mingw]
69 gem "pg", "~> 0.18.1", :platforms => [:mri, :mingw, :x64_mingw]
69 gem "activerecord-jdbcpostgresql-adapter", :platforms => :jruby
70 gem "activerecord-jdbcpostgresql-adapter", :platforms => :jruby
70 when /sqlite3/
71 when /sqlite3/
71 gem "sqlite3", :platforms => [:mri, :mingw, :x64_mingw]
72 gem "sqlite3", :platforms => [:mri, :mingw, :x64_mingw]
72 gem "jdbc-sqlite3", ">= 3.8.10.1", :platforms => :jruby
73 gem "jdbc-sqlite3", ">= 3.8.10.1", :platforms => :jruby
73 gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
74 gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
74 when /sqlserver/
75 when /sqlserver/
75 gem "tiny_tds", "~> 0.6.2", :platforms => [:mri, :mingw, :x64_mingw]
76 gem "tiny_tds", "~> 0.6.2", :platforms => [:mri, :mingw, :x64_mingw]
76 gem "activerecord-sqlserver-adapter", :platforms => [:mri, :mingw, :x64_mingw]
77 gem "activerecord-sqlserver-adapter", :platforms => [:mri, :mingw, :x64_mingw]
77 else
78 else
78 warn("Unknown database adapter `#{adapter}` found in config/database.yml, use Gemfile.local to load your own database gems")
79 warn("Unknown database adapter `#{adapter}` found in config/database.yml, use Gemfile.local to load your own database gems")
79 end
80 end
80 end
81 end
81 else
82 else
82 warn("No adapter found in config/database.yml, please configure it first")
83 warn("No adapter found in config/database.yml, please configure it first")
83 end
84 end
84 else
85 else
85 warn("Please configure your config/database.yml first")
86 warn("Please configure your config/database.yml first")
86 end
87 end
87
88
88 group :development do
89 group :development do
89 gem "rdoc", ">= 2.4.2"
90 gem "rdoc", ">= 2.4.2"
90 gem "yard"
91 gem "yard"
91 end
92 end
92
93
93 group :test do
94 group :test do
94 gem "minitest"
95 gem "minitest"
95 gem "rails-dom-testing"
96 gem "rails-dom-testing"
96 gem "mocha"
97 gem "mocha"
97 gem "simplecov", "~> 0.9.1", :require => false
98 gem "simplecov", "~> 0.9.1", :require => false
98 # For running UI tests
99 # For running UI tests
99 gem "capybara"
100 gem "capybara"
100 gem "selenium-webdriver"
101 gem "selenium-webdriver"
101 end
102 end
102
103
103 local_gemfile = File.join(File.dirname(__FILE__), "Gemfile.local")
104 local_gemfile = File.join(File.dirname(__FILE__), "Gemfile.local")
104 if File.exists?(local_gemfile)
105 if File.exists?(local_gemfile)
105 eval_gemfile local_gemfile
106 eval_gemfile local_gemfile
106 end
107 end
107
108
108 # Load plugins' Gemfiles
109 # Load plugins' Gemfiles
109 Dir.glob File.expand_path("../plugins/*/{Gemfile,PluginGemfile}", __FILE__) do |file|
110 Dir.glob File.expand_path("../plugins/*/{Gemfile,PluginGemfile}", __FILE__) do |file|
110 eval_gemfile file
111 eval_gemfile file
111 end
112 end
@@ -1,538 +1,541
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2015 Jean-Philippe Lang
2 # Copyright (C) 2006-2015 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 require 'roadie'
19
18 class Mailer < ActionMailer::Base
20 class Mailer < ActionMailer::Base
19 layout 'mailer'
21 layout 'mailer'
20 helper :application
22 helper :application
21 helper :issues
23 helper :issues
22 helper :custom_fields
24 helper :custom_fields
23
25
24 include Redmine::I18n
26 include Redmine::I18n
27 include Roadie::Rails::Automatic
25
28
26 def self.default_url_options
29 def self.default_url_options
27 options = {:protocol => Setting.protocol}
30 options = {:protocol => Setting.protocol}
28 if Setting.host_name.to_s =~ /\A(https?\:\/\/)?(.+?)(\:(\d+))?(\/.+)?\z/i
31 if Setting.host_name.to_s =~ /\A(https?\:\/\/)?(.+?)(\:(\d+))?(\/.+)?\z/i
29 host, port, prefix = $2, $4, $5
32 host, port, prefix = $2, $4, $5
30 options.merge!({
33 options.merge!({
31 :host => host, :port => port, :script_name => prefix
34 :host => host, :port => port, :script_name => prefix
32 })
35 })
33 else
36 else
34 options[:host] = Setting.host_name
37 options[:host] = Setting.host_name
35 end
38 end
36 options
39 options
37 end
40 end
38
41
39 # Builds a mail for notifying to_users and cc_users about a new issue
42 # Builds a mail for notifying to_users and cc_users about a new issue
40 def issue_add(issue, to_users, cc_users)
43 def issue_add(issue, to_users, cc_users)
41 redmine_headers 'Project' => issue.project.identifier,
44 redmine_headers 'Project' => issue.project.identifier,
42 'Issue-Id' => issue.id,
45 'Issue-Id' => issue.id,
43 'Issue-Author' => issue.author.login
46 'Issue-Author' => issue.author.login
44 redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to
47 redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to
45 message_id issue
48 message_id issue
46 references issue
49 references issue
47 @author = issue.author
50 @author = issue.author
48 @issue = issue
51 @issue = issue
49 @users = to_users + cc_users
52 @users = to_users + cc_users
50 @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue)
53 @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue)
51 mail :to => to_users,
54 mail :to => to_users,
52 :cc => cc_users,
55 :cc => cc_users,
53 :subject => "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] (#{issue.status.name}) #{issue.subject}"
56 :subject => "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] (#{issue.status.name}) #{issue.subject}"
54 end
57 end
55
58
56 # Notifies users about a new issue
59 # Notifies users about a new issue
57 def self.deliver_issue_add(issue)
60 def self.deliver_issue_add(issue)
58 to = issue.notified_users
61 to = issue.notified_users
59 cc = issue.notified_watchers - to
62 cc = issue.notified_watchers - to
60 issue.each_notification(to + cc) do |users|
63 issue.each_notification(to + cc) do |users|
61 Mailer.issue_add(issue, to & users, cc & users).deliver
64 Mailer.issue_add(issue, to & users, cc & users).deliver
62 end
65 end
63 end
66 end
64
67
65 # Builds a mail for notifying to_users and cc_users about an issue update
68 # Builds a mail for notifying to_users and cc_users about an issue update
66 def issue_edit(journal, to_users, cc_users)
69 def issue_edit(journal, to_users, cc_users)
67 issue = journal.journalized
70 issue = journal.journalized
68 redmine_headers 'Project' => issue.project.identifier,
71 redmine_headers 'Project' => issue.project.identifier,
69 'Issue-Id' => issue.id,
72 'Issue-Id' => issue.id,
70 'Issue-Author' => issue.author.login
73 'Issue-Author' => issue.author.login
71 redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to
74 redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to
72 message_id journal
75 message_id journal
73 references issue
76 references issue
74 @author = journal.user
77 @author = journal.user
75 s = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] "
78 s = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] "
76 s << "(#{issue.status.name}) " if journal.new_value_for('status_id')
79 s << "(#{issue.status.name}) " if journal.new_value_for('status_id')
77 s << issue.subject
80 s << issue.subject
78 @issue = issue
81 @issue = issue
79 @users = to_users + cc_users
82 @users = to_users + cc_users
80 @journal = journal
83 @journal = journal
81 @journal_details = journal.visible_details(@users.first)
84 @journal_details = journal.visible_details(@users.first)
82 @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue, :anchor => "change-#{journal.id}")
85 @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue, :anchor => "change-#{journal.id}")
83 mail :to => to_users,
86 mail :to => to_users,
84 :cc => cc_users,
87 :cc => cc_users,
85 :subject => s
88 :subject => s
86 end
89 end
87
90
88 # Notifies users about an issue update
91 # Notifies users about an issue update
89 def self.deliver_issue_edit(journal)
92 def self.deliver_issue_edit(journal)
90 issue = journal.journalized.reload
93 issue = journal.journalized.reload
91 to = journal.notified_users
94 to = journal.notified_users
92 cc = journal.notified_watchers - to
95 cc = journal.notified_watchers - to
93 journal.each_notification(to + cc) do |users|
96 journal.each_notification(to + cc) do |users|
94 issue.each_notification(users) do |users2|
97 issue.each_notification(users) do |users2|
95 Mailer.issue_edit(journal, to & users2, cc & users2).deliver
98 Mailer.issue_edit(journal, to & users2, cc & users2).deliver
96 end
99 end
97 end
100 end
98 end
101 end
99
102
100 def reminder(user, issues, days)
103 def reminder(user, issues, days)
101 set_language_if_valid user.language
104 set_language_if_valid user.language
102 @issues = issues
105 @issues = issues
103 @days = days
106 @days = days
104 @issues_url = url_for(:controller => 'issues', :action => 'index',
107 @issues_url = url_for(:controller => 'issues', :action => 'index',
105 :set_filter => 1, :assigned_to_id => user.id,
108 :set_filter => 1, :assigned_to_id => user.id,
106 :sort => 'due_date:asc')
109 :sort => 'due_date:asc')
107 mail :to => user,
110 mail :to => user,
108 :subject => l(:mail_subject_reminder, :count => issues.size, :days => days)
111 :subject => l(:mail_subject_reminder, :count => issues.size, :days => days)
109 end
112 end
110
113
111 # Builds a Mail::Message object used to email users belonging to the added document's project.
114 # Builds a Mail::Message object used to email users belonging to the added document's project.
112 #
115 #
113 # Example:
116 # Example:
114 # document_added(document) => Mail::Message object
117 # document_added(document) => Mail::Message object
115 # Mailer.document_added(document).deliver => sends an email to the document's project recipients
118 # Mailer.document_added(document).deliver => sends an email to the document's project recipients
116 def document_added(document)
119 def document_added(document)
117 redmine_headers 'Project' => document.project.identifier
120 redmine_headers 'Project' => document.project.identifier
118 @author = User.current
121 @author = User.current
119 @document = document
122 @document = document
120 @document_url = url_for(:controller => 'documents', :action => 'show', :id => document)
123 @document_url = url_for(:controller => 'documents', :action => 'show', :id => document)
121 mail :to => document.notified_users,
124 mail :to => document.notified_users,
122 :subject => "[#{document.project.name}] #{l(:label_document_new)}: #{document.title}"
125 :subject => "[#{document.project.name}] #{l(:label_document_new)}: #{document.title}"
123 end
126 end
124
127
125 # Builds a Mail::Message object used to email recipients of a project when an attachements are added.
128 # Builds a Mail::Message object used to email recipients of a project when an attachements are added.
126 #
129 #
127 # Example:
130 # Example:
128 # attachments_added(attachments) => Mail::Message object
131 # attachments_added(attachments) => Mail::Message object
129 # Mailer.attachments_added(attachments).deliver => sends an email to the project's recipients
132 # Mailer.attachments_added(attachments).deliver => sends an email to the project's recipients
130 def attachments_added(attachments)
133 def attachments_added(attachments)
131 container = attachments.first.container
134 container = attachments.first.container
132 added_to = ''
135 added_to = ''
133 added_to_url = ''
136 added_to_url = ''
134 @author = attachments.first.author
137 @author = attachments.first.author
135 case container.class.name
138 case container.class.name
136 when 'Project'
139 when 'Project'
137 added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container)
140 added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container)
138 added_to = "#{l(:label_project)}: #{container}"
141 added_to = "#{l(:label_project)}: #{container}"
139 recipients = container.project.notified_users.select {|user| user.allowed_to?(:view_files, container.project)}
142 recipients = container.project.notified_users.select {|user| user.allowed_to?(:view_files, container.project)}
140 when 'Version'
143 when 'Version'
141 added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container.project)
144 added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container.project)
142 added_to = "#{l(:label_version)}: #{container.name}"
145 added_to = "#{l(:label_version)}: #{container.name}"
143 recipients = container.project.notified_users.select {|user| user.allowed_to?(:view_files, container.project)}
146 recipients = container.project.notified_users.select {|user| user.allowed_to?(:view_files, container.project)}
144 when 'Document'
147 when 'Document'
145 added_to_url = url_for(:controller => 'documents', :action => 'show', :id => container.id)
148 added_to_url = url_for(:controller => 'documents', :action => 'show', :id => container.id)
146 added_to = "#{l(:label_document)}: #{container.title}"
149 added_to = "#{l(:label_document)}: #{container.title}"
147 recipients = container.notified_users
150 recipients = container.notified_users
148 end
151 end
149 redmine_headers 'Project' => container.project.identifier
152 redmine_headers 'Project' => container.project.identifier
150 @attachments = attachments
153 @attachments = attachments
151 @added_to = added_to
154 @added_to = added_to
152 @added_to_url = added_to_url
155 @added_to_url = added_to_url
153 mail :to => recipients,
156 mail :to => recipients,
154 :subject => "[#{container.project.name}] #{l(:label_attachment_new)}"
157 :subject => "[#{container.project.name}] #{l(:label_attachment_new)}"
155 end
158 end
156
159
157 # Builds a Mail::Message object used to email recipients of a news' project when a news item is added.
160 # Builds a Mail::Message object used to email recipients of a news' project when a news item is added.
158 #
161 #
159 # Example:
162 # Example:
160 # news_added(news) => Mail::Message object
163 # news_added(news) => Mail::Message object
161 # Mailer.news_added(news).deliver => sends an email to the news' project recipients
164 # Mailer.news_added(news).deliver => sends an email to the news' project recipients
162 def news_added(news)
165 def news_added(news)
163 redmine_headers 'Project' => news.project.identifier
166 redmine_headers 'Project' => news.project.identifier
164 @author = news.author
167 @author = news.author
165 message_id news
168 message_id news
166 references news
169 references news
167 @news = news
170 @news = news
168 @news_url = url_for(:controller => 'news', :action => 'show', :id => news)
171 @news_url = url_for(:controller => 'news', :action => 'show', :id => news)
169 mail :to => news.notified_users,
172 mail :to => news.notified_users,
170 :cc => news.notified_watchers_for_added_news,
173 :cc => news.notified_watchers_for_added_news,
171 :subject => "[#{news.project.name}] #{l(:label_news)}: #{news.title}"
174 :subject => "[#{news.project.name}] #{l(:label_news)}: #{news.title}"
172 end
175 end
173
176
174 # Builds a Mail::Message object used to email recipients of a news' project when a news comment is added.
177 # Builds a Mail::Message object used to email recipients of a news' project when a news comment is added.
175 #
178 #
176 # Example:
179 # Example:
177 # news_comment_added(comment) => Mail::Message object
180 # news_comment_added(comment) => Mail::Message object
178 # Mailer.news_comment_added(comment) => sends an email to the news' project recipients
181 # Mailer.news_comment_added(comment) => sends an email to the news' project recipients
179 def news_comment_added(comment)
182 def news_comment_added(comment)
180 news = comment.commented
183 news = comment.commented
181 redmine_headers 'Project' => news.project.identifier
184 redmine_headers 'Project' => news.project.identifier
182 @author = comment.author
185 @author = comment.author
183 message_id comment
186 message_id comment
184 references news
187 references news
185 @news = news
188 @news = news
186 @comment = comment
189 @comment = comment
187 @news_url = url_for(:controller => 'news', :action => 'show', :id => news)
190 @news_url = url_for(:controller => 'news', :action => 'show', :id => news)
188 mail :to => news.notified_users,
191 mail :to => news.notified_users,
189 :cc => news.notified_watchers,
192 :cc => news.notified_watchers,
190 :subject => "Re: [#{news.project.name}] #{l(:label_news)}: #{news.title}"
193 :subject => "Re: [#{news.project.name}] #{l(:label_news)}: #{news.title}"
191 end
194 end
192
195
193 # Builds a Mail::Message object used to email the recipients of the specified message that was posted.
196 # Builds a Mail::Message object used to email the recipients of the specified message that was posted.
194 #
197 #
195 # Example:
198 # Example:
196 # message_posted(message) => Mail::Message object
199 # message_posted(message) => Mail::Message object
197 # Mailer.message_posted(message).deliver => sends an email to the recipients
200 # Mailer.message_posted(message).deliver => sends an email to the recipients
198 def message_posted(message)
201 def message_posted(message)
199 redmine_headers 'Project' => message.project.identifier,
202 redmine_headers 'Project' => message.project.identifier,
200 'Topic-Id' => (message.parent_id || message.id)
203 'Topic-Id' => (message.parent_id || message.id)
201 @author = message.author
204 @author = message.author
202 message_id message
205 message_id message
203 references message.root
206 references message.root
204 recipients = message.notified_users
207 recipients = message.notified_users
205 cc = ((message.root.notified_watchers + message.board.notified_watchers).uniq - recipients)
208 cc = ((message.root.notified_watchers + message.board.notified_watchers).uniq - recipients)
206 @message = message
209 @message = message
207 @message_url = url_for(message.event_url)
210 @message_url = url_for(message.event_url)
208 mail :to => recipients,
211 mail :to => recipients,
209 :cc => cc,
212 :cc => cc,
210 :subject => "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}"
213 :subject => "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}"
211 end
214 end
212
215
213 # Builds a Mail::Message object used to email the recipients of a project of the specified wiki content was added.
216 # Builds a Mail::Message object used to email the recipients of a project of the specified wiki content was added.
214 #
217 #
215 # Example:
218 # Example:
216 # wiki_content_added(wiki_content) => Mail::Message object
219 # wiki_content_added(wiki_content) => Mail::Message object
217 # Mailer.wiki_content_added(wiki_content).deliver => sends an email to the project's recipients
220 # Mailer.wiki_content_added(wiki_content).deliver => sends an email to the project's recipients
218 def wiki_content_added(wiki_content)
221 def wiki_content_added(wiki_content)
219 redmine_headers 'Project' => wiki_content.project.identifier,
222 redmine_headers 'Project' => wiki_content.project.identifier,
220 'Wiki-Page-Id' => wiki_content.page.id
223 'Wiki-Page-Id' => wiki_content.page.id
221 @author = wiki_content.author
224 @author = wiki_content.author
222 message_id wiki_content
225 message_id wiki_content
223 recipients = wiki_content.notified_users
226 recipients = wiki_content.notified_users
224 cc = wiki_content.page.wiki.notified_watchers - recipients
227 cc = wiki_content.page.wiki.notified_watchers - recipients
225 @wiki_content = wiki_content
228 @wiki_content = wiki_content
226 @wiki_content_url = url_for(:controller => 'wiki', :action => 'show',
229 @wiki_content_url = url_for(:controller => 'wiki', :action => 'show',
227 :project_id => wiki_content.project,
230 :project_id => wiki_content.project,
228 :id => wiki_content.page.title)
231 :id => wiki_content.page.title)
229 mail :to => recipients,
232 mail :to => recipients,
230 :cc => cc,
233 :cc => cc,
231 :subject => "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_added, :id => wiki_content.page.pretty_title)}"
234 :subject => "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_added, :id => wiki_content.page.pretty_title)}"
232 end
235 end
233
236
234 # Builds a Mail::Message object used to email the recipients of a project of the specified wiki content was updated.
237 # Builds a Mail::Message object used to email the recipients of a project of the specified wiki content was updated.
235 #
238 #
236 # Example:
239 # Example:
237 # wiki_content_updated(wiki_content) => Mail::Message object
240 # wiki_content_updated(wiki_content) => Mail::Message object
238 # Mailer.wiki_content_updated(wiki_content).deliver => sends an email to the project's recipients
241 # Mailer.wiki_content_updated(wiki_content).deliver => sends an email to the project's recipients
239 def wiki_content_updated(wiki_content)
242 def wiki_content_updated(wiki_content)
240 redmine_headers 'Project' => wiki_content.project.identifier,
243 redmine_headers 'Project' => wiki_content.project.identifier,
241 'Wiki-Page-Id' => wiki_content.page.id
244 'Wiki-Page-Id' => wiki_content.page.id
242 @author = wiki_content.author
245 @author = wiki_content.author
243 message_id wiki_content
246 message_id wiki_content
244 recipients = wiki_content.notified_users
247 recipients = wiki_content.notified_users
245 cc = wiki_content.page.wiki.notified_watchers + wiki_content.page.notified_watchers - recipients
248 cc = wiki_content.page.wiki.notified_watchers + wiki_content.page.notified_watchers - recipients
246 @wiki_content = wiki_content
249 @wiki_content = wiki_content
247 @wiki_content_url = url_for(:controller => 'wiki', :action => 'show',
250 @wiki_content_url = url_for(:controller => 'wiki', :action => 'show',
248 :project_id => wiki_content.project,
251 :project_id => wiki_content.project,
249 :id => wiki_content.page.title)
252 :id => wiki_content.page.title)
250 @wiki_diff_url = url_for(:controller => 'wiki', :action => 'diff',
253 @wiki_diff_url = url_for(:controller => 'wiki', :action => 'diff',
251 :project_id => wiki_content.project, :id => wiki_content.page.title,
254 :project_id => wiki_content.project, :id => wiki_content.page.title,
252 :version => wiki_content.version)
255 :version => wiki_content.version)
253 mail :to => recipients,
256 mail :to => recipients,
254 :cc => cc,
257 :cc => cc,
255 :subject => "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_updated, :id => wiki_content.page.pretty_title)}"
258 :subject => "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_updated, :id => wiki_content.page.pretty_title)}"
256 end
259 end
257
260
258 # Builds a Mail::Message object used to email the specified user their account information.
261 # Builds a Mail::Message object used to email the specified user their account information.
259 #
262 #
260 # Example:
263 # Example:
261 # account_information(user, password) => Mail::Message object
264 # account_information(user, password) => Mail::Message object
262 # Mailer.account_information(user, password).deliver => sends account information to the user
265 # Mailer.account_information(user, password).deliver => sends account information to the user
263 def account_information(user, password)
266 def account_information(user, password)
264 set_language_if_valid user.language
267 set_language_if_valid user.language
265 @user = user
268 @user = user
266 @password = password
269 @password = password
267 @login_url = url_for(:controller => 'account', :action => 'login')
270 @login_url = url_for(:controller => 'account', :action => 'login')
268 mail :to => user.mail,
271 mail :to => user.mail,
269 :subject => l(:mail_subject_register, Setting.app_title)
272 :subject => l(:mail_subject_register, Setting.app_title)
270 end
273 end
271
274
272 # Builds a Mail::Message object used to email all active administrators of an account activation request.
275 # Builds a Mail::Message object used to email all active administrators of an account activation request.
273 #
276 #
274 # Example:
277 # Example:
275 # account_activation_request(user) => Mail::Message object
278 # account_activation_request(user) => Mail::Message object
276 # Mailer.account_activation_request(user).deliver => sends an email to all active administrators
279 # Mailer.account_activation_request(user).deliver => sends an email to all active administrators
277 def account_activation_request(user)
280 def account_activation_request(user)
278 # Send the email to all active administrators
281 # Send the email to all active administrators
279 recipients = User.active.where(:admin => true)
282 recipients = User.active.where(:admin => true)
280 @user = user
283 @user = user
281 @url = url_for(:controller => 'users', :action => 'index',
284 @url = url_for(:controller => 'users', :action => 'index',
282 :status => User::STATUS_REGISTERED,
285 :status => User::STATUS_REGISTERED,
283 :sort_key => 'created_on', :sort_order => 'desc')
286 :sort_key => 'created_on', :sort_order => 'desc')
284 mail :to => recipients,
287 mail :to => recipients,
285 :subject => l(:mail_subject_account_activation_request, Setting.app_title)
288 :subject => l(:mail_subject_account_activation_request, Setting.app_title)
286 end
289 end
287
290
288 # Builds a Mail::Message object used to email the specified user that their account was activated by an administrator.
291 # Builds a Mail::Message object used to email the specified user that their account was activated by an administrator.
289 #
292 #
290 # Example:
293 # Example:
291 # account_activated(user) => Mail::Message object
294 # account_activated(user) => Mail::Message object
292 # Mailer.account_activated(user).deliver => sends an email to the registered user
295 # Mailer.account_activated(user).deliver => sends an email to the registered user
293 def account_activated(user)
296 def account_activated(user)
294 set_language_if_valid user.language
297 set_language_if_valid user.language
295 @user = user
298 @user = user
296 @login_url = url_for(:controller => 'account', :action => 'login')
299 @login_url = url_for(:controller => 'account', :action => 'login')
297 mail :to => user.mail,
300 mail :to => user.mail,
298 :subject => l(:mail_subject_register, Setting.app_title)
301 :subject => l(:mail_subject_register, Setting.app_title)
299 end
302 end
300
303
301 def lost_password(token, recipient=nil)
304 def lost_password(token, recipient=nil)
302 set_language_if_valid(token.user.language)
305 set_language_if_valid(token.user.language)
303 recipient ||= token.user.mail
306 recipient ||= token.user.mail
304 @token = token
307 @token = token
305 @url = url_for(:controller => 'account', :action => 'lost_password', :token => token.value)
308 @url = url_for(:controller => 'account', :action => 'lost_password', :token => token.value)
306 mail :to => recipient,
309 mail :to => recipient,
307 :subject => l(:mail_subject_lost_password, Setting.app_title)
310 :subject => l(:mail_subject_lost_password, Setting.app_title)
308 end
311 end
309
312
310 def register(token)
313 def register(token)
311 set_language_if_valid(token.user.language)
314 set_language_if_valid(token.user.language)
312 @token = token
315 @token = token
313 @url = url_for(:controller => 'account', :action => 'activate', :token => token.value)
316 @url = url_for(:controller => 'account', :action => 'activate', :token => token.value)
314 mail :to => token.user.mail,
317 mail :to => token.user.mail,
315 :subject => l(:mail_subject_register, Setting.app_title)
318 :subject => l(:mail_subject_register, Setting.app_title)
316 end
319 end
317
320
318 def test_email(user)
321 def test_email(user)
319 set_language_if_valid(user.language)
322 set_language_if_valid(user.language)
320 @url = url_for(:controller => 'welcome')
323 @url = url_for(:controller => 'welcome')
321 mail :to => user.mail,
324 mail :to => user.mail,
322 :subject => 'Redmine test'
325 :subject => 'Redmine test'
323 end
326 end
324
327
325 # Sends reminders to issue assignees
328 # Sends reminders to issue assignees
326 # Available options:
329 # Available options:
327 # * :days => how many days in the future to remind about (defaults to 7)
330 # * :days => how many days in the future to remind about (defaults to 7)
328 # * :tracker => id of tracker for filtering issues (defaults to all trackers)
331 # * :tracker => id of tracker for filtering issues (defaults to all trackers)
329 # * :project => id or identifier of project to process (defaults to all projects)
332 # * :project => id or identifier of project to process (defaults to all projects)
330 # * :users => array of user/group ids who should be reminded
333 # * :users => array of user/group ids who should be reminded
331 # * :version => name of target version for filtering issues (defaults to none)
334 # * :version => name of target version for filtering issues (defaults to none)
332 def self.reminders(options={})
335 def self.reminders(options={})
333 days = options[:days] || 7
336 days = options[:days] || 7
334 project = options[:project] ? Project.find(options[:project]) : nil
337 project = options[:project] ? Project.find(options[:project]) : nil
335 tracker = options[:tracker] ? Tracker.find(options[:tracker]) : nil
338 tracker = options[:tracker] ? Tracker.find(options[:tracker]) : nil
336 target_version_id = options[:version] ? Version.named(options[:version]).pluck(:id) : nil
339 target_version_id = options[:version] ? Version.named(options[:version]).pluck(:id) : nil
337 if options[:version] && target_version_id.blank?
340 if options[:version] && target_version_id.blank?
338 raise ActiveRecord::RecordNotFound.new("Couldn't find Version with named #{options[:version]}")
341 raise ActiveRecord::RecordNotFound.new("Couldn't find Version with named #{options[:version]}")
339 end
342 end
340 user_ids = options[:users]
343 user_ids = options[:users]
341
344
342 scope = Issue.open.where("#{Issue.table_name}.assigned_to_id IS NOT NULL" +
345 scope = Issue.open.where("#{Issue.table_name}.assigned_to_id IS NOT NULL" +
343 " AND #{Project.table_name}.status = #{Project::STATUS_ACTIVE}" +
346 " AND #{Project.table_name}.status = #{Project::STATUS_ACTIVE}" +
344 " AND #{Issue.table_name}.due_date <= ?", days.day.from_now.to_date
347 " AND #{Issue.table_name}.due_date <= ?", days.day.from_now.to_date
345 )
348 )
346 scope = scope.where(:assigned_to_id => user_ids) if user_ids.present?
349 scope = scope.where(:assigned_to_id => user_ids) if user_ids.present?
347 scope = scope.where(:project_id => project.id) if project
350 scope = scope.where(:project_id => project.id) if project
348 scope = scope.where(:fixed_version_id => target_version_id) if target_version_id.present?
351 scope = scope.where(:fixed_version_id => target_version_id) if target_version_id.present?
349 scope = scope.where(:tracker_id => tracker.id) if tracker
352 scope = scope.where(:tracker_id => tracker.id) if tracker
350 issues_by_assignee = scope.includes(:status, :assigned_to, :project, :tracker).
353 issues_by_assignee = scope.includes(:status, :assigned_to, :project, :tracker).
351 group_by(&:assigned_to)
354 group_by(&:assigned_to)
352 issues_by_assignee.keys.each do |assignee|
355 issues_by_assignee.keys.each do |assignee|
353 if assignee.is_a?(Group)
356 if assignee.is_a?(Group)
354 assignee.users.each do |user|
357 assignee.users.each do |user|
355 issues_by_assignee[user] ||= []
358 issues_by_assignee[user] ||= []
356 issues_by_assignee[user] += issues_by_assignee[assignee]
359 issues_by_assignee[user] += issues_by_assignee[assignee]
357 end
360 end
358 end
361 end
359 end
362 end
360
363
361 issues_by_assignee.each do |assignee, issues|
364 issues_by_assignee.each do |assignee, issues|
362 reminder(assignee, issues, days).deliver if assignee.is_a?(User) && assignee.active?
365 reminder(assignee, issues, days).deliver if assignee.is_a?(User) && assignee.active?
363 end
366 end
364 end
367 end
365
368
366 # Activates/desactivates email deliveries during +block+
369 # Activates/desactivates email deliveries during +block+
367 def self.with_deliveries(enabled = true, &block)
370 def self.with_deliveries(enabled = true, &block)
368 was_enabled = ActionMailer::Base.perform_deliveries
371 was_enabled = ActionMailer::Base.perform_deliveries
369 ActionMailer::Base.perform_deliveries = !!enabled
372 ActionMailer::Base.perform_deliveries = !!enabled
370 yield
373 yield
371 ensure
374 ensure
372 ActionMailer::Base.perform_deliveries = was_enabled
375 ActionMailer::Base.perform_deliveries = was_enabled
373 end
376 end
374
377
375 # Sends emails synchronously in the given block
378 # Sends emails synchronously in the given block
376 def self.with_synched_deliveries(&block)
379 def self.with_synched_deliveries(&block)
377 saved_method = ActionMailer::Base.delivery_method
380 saved_method = ActionMailer::Base.delivery_method
378 if m = saved_method.to_s.match(%r{^async_(.+)$})
381 if m = saved_method.to_s.match(%r{^async_(.+)$})
379 synched_method = m[1]
382 synched_method = m[1]
380 ActionMailer::Base.delivery_method = synched_method.to_sym
383 ActionMailer::Base.delivery_method = synched_method.to_sym
381 ActionMailer::Base.send "#{synched_method}_settings=", ActionMailer::Base.send("async_#{synched_method}_settings")
384 ActionMailer::Base.send "#{synched_method}_settings=", ActionMailer::Base.send("async_#{synched_method}_settings")
382 end
385 end
383 yield
386 yield
384 ensure
387 ensure
385 ActionMailer::Base.delivery_method = saved_method
388 ActionMailer::Base.delivery_method = saved_method
386 end
389 end
387
390
388 def mail(headers={}, &block)
391 def mail(headers={}, &block)
389 headers.reverse_merge! 'X-Mailer' => 'Redmine',
392 headers.reverse_merge! 'X-Mailer' => 'Redmine',
390 'X-Redmine-Host' => Setting.host_name,
393 'X-Redmine-Host' => Setting.host_name,
391 'X-Redmine-Site' => Setting.app_title,
394 'X-Redmine-Site' => Setting.app_title,
392 'X-Auto-Response-Suppress' => 'All',
395 'X-Auto-Response-Suppress' => 'All',
393 'Auto-Submitted' => 'auto-generated',
396 'Auto-Submitted' => 'auto-generated',
394 'From' => Setting.mail_from,
397 'From' => Setting.mail_from,
395 'List-Id' => "<#{Setting.mail_from.to_s.gsub('@', '.')}>"
398 'List-Id' => "<#{Setting.mail_from.to_s.gsub('@', '.')}>"
396
399
397 # Replaces users with their email addresses
400 # Replaces users with their email addresses
398 [:to, :cc, :bcc].each do |key|
401 [:to, :cc, :bcc].each do |key|
399 if headers[key].present?
402 if headers[key].present?
400 headers[key] = self.class.email_addresses(headers[key])
403 headers[key] = self.class.email_addresses(headers[key])
401 end
404 end
402 end
405 end
403
406
404 # Removes the author from the recipients and cc
407 # Removes the author from the recipients and cc
405 # if the author does not want to receive notifications
408 # if the author does not want to receive notifications
406 # about what the author do
409 # about what the author do
407 if @author && @author.logged? && @author.pref.no_self_notified
410 if @author && @author.logged? && @author.pref.no_self_notified
408 addresses = @author.mails
411 addresses = @author.mails
409 headers[:to] -= addresses if headers[:to].is_a?(Array)
412 headers[:to] -= addresses if headers[:to].is_a?(Array)
410 headers[:cc] -= addresses if headers[:cc].is_a?(Array)
413 headers[:cc] -= addresses if headers[:cc].is_a?(Array)
411 end
414 end
412
415
413 if @author && @author.logged?
416 if @author && @author.logged?
414 redmine_headers 'Sender' => @author.login
417 redmine_headers 'Sender' => @author.login
415 end
418 end
416
419
417 # Blind carbon copy recipients
420 # Blind carbon copy recipients
418 if Setting.bcc_recipients?
421 if Setting.bcc_recipients?
419 headers[:bcc] = [headers[:to], headers[:cc]].flatten.uniq.reject(&:blank?)
422 headers[:bcc] = [headers[:to], headers[:cc]].flatten.uniq.reject(&:blank?)
420 headers[:to] = nil
423 headers[:to] = nil
421 headers[:cc] = nil
424 headers[:cc] = nil
422 end
425 end
423
426
424 if @message_id_object
427 if @message_id_object
425 headers[:message_id] = "<#{self.class.message_id_for(@message_id_object)}>"
428 headers[:message_id] = "<#{self.class.message_id_for(@message_id_object)}>"
426 end
429 end
427 if @references_objects
430 if @references_objects
428 headers[:references] = @references_objects.collect {|o| "<#{self.class.references_for(o)}>"}.join(' ')
431 headers[:references] = @references_objects.collect {|o| "<#{self.class.references_for(o)}>"}.join(' ')
429 end
432 end
430
433
431 m = if block_given?
434 m = if block_given?
432 super headers, &block
435 super headers, &block
433 else
436 else
434 super headers do |format|
437 super headers do |format|
435 format.text
438 format.text
436 format.html unless Setting.plain_text_mail?
439 format.html unless Setting.plain_text_mail?
437 end
440 end
438 end
441 end
439 set_language_if_valid @initial_language
442 set_language_if_valid @initial_language
440
443
441 m
444 m
442 end
445 end
443
446
444 def initialize(*args)
447 def initialize(*args)
445 @initial_language = current_language
448 @initial_language = current_language
446 set_language_if_valid Setting.default_language
449 set_language_if_valid Setting.default_language
447 super
450 super
448 end
451 end
449
452
450 def self.deliver_mail(mail)
453 def self.deliver_mail(mail)
451 return false if mail.to.blank? && mail.cc.blank? && mail.bcc.blank?
454 return false if mail.to.blank? && mail.cc.blank? && mail.bcc.blank?
452 begin
455 begin
453 # Log errors when raise_delivery_errors is set to false, Rails does not
456 # Log errors when raise_delivery_errors is set to false, Rails does not
454 mail.raise_delivery_errors = true
457 mail.raise_delivery_errors = true
455 super
458 super
456 rescue Exception => e
459 rescue Exception => e
457 if ActionMailer::Base.raise_delivery_errors
460 if ActionMailer::Base.raise_delivery_errors
458 raise e
461 raise e
459 else
462 else
460 Rails.logger.error "Email delivery error: #{e.message}"
463 Rails.logger.error "Email delivery error: #{e.message}"
461 end
464 end
462 end
465 end
463 end
466 end
464
467
465 def self.method_missing(method, *args, &block)
468 def self.method_missing(method, *args, &block)
466 if m = method.to_s.match(%r{^deliver_(.+)$})
469 if m = method.to_s.match(%r{^deliver_(.+)$})
467 ActiveSupport::Deprecation.warn "Mailer.deliver_#{m[1]}(*args) is deprecated. Use Mailer.#{m[1]}(*args).deliver instead."
470 ActiveSupport::Deprecation.warn "Mailer.deliver_#{m[1]}(*args) is deprecated. Use Mailer.#{m[1]}(*args).deliver instead."
468 send(m[1], *args).deliver
471 send(m[1], *args).deliver
469 else
472 else
470 super
473 super
471 end
474 end
472 end
475 end
473
476
474 # Returns an array of email addresses to notify by
477 # Returns an array of email addresses to notify by
475 # replacing users in arg with their notified email addresses
478 # replacing users in arg with their notified email addresses
476 #
479 #
477 # Example:
480 # Example:
478 # Mailer.email_addresses(users)
481 # Mailer.email_addresses(users)
479 # => ["foo@example.net", "bar@example.net"]
482 # => ["foo@example.net", "bar@example.net"]
480 def self.email_addresses(arg)
483 def self.email_addresses(arg)
481 arr = Array.wrap(arg)
484 arr = Array.wrap(arg)
482 mails = arr.reject {|a| a.is_a? Principal}
485 mails = arr.reject {|a| a.is_a? Principal}
483 users = arr - mails
486 users = arr - mails
484 if users.any?
487 if users.any?
485 mails += EmailAddress.
488 mails += EmailAddress.
486 where(:user_id => users.map(&:id)).
489 where(:user_id => users.map(&:id)).
487 where("is_default = ? OR notify = ?", true, true).
490 where("is_default = ? OR notify = ?", true, true).
488 pluck(:address)
491 pluck(:address)
489 end
492 end
490 mails
493 mails
491 end
494 end
492
495
493 private
496 private
494
497
495 # Appends a Redmine header field (name is prepended with 'X-Redmine-')
498 # Appends a Redmine header field (name is prepended with 'X-Redmine-')
496 def redmine_headers(h)
499 def redmine_headers(h)
497 h.each { |k,v| headers["X-Redmine-#{k}"] = v.to_s }
500 h.each { |k,v| headers["X-Redmine-#{k}"] = v.to_s }
498 end
501 end
499
502
500 def self.token_for(object, rand=true)
503 def self.token_for(object, rand=true)
501 timestamp = object.send(object.respond_to?(:created_on) ? :created_on : :updated_on)
504 timestamp = object.send(object.respond_to?(:created_on) ? :created_on : :updated_on)
502 hash = [
505 hash = [
503 "redmine",
506 "redmine",
504 "#{object.class.name.demodulize.underscore}-#{object.id}",
507 "#{object.class.name.demodulize.underscore}-#{object.id}",
505 timestamp.strftime("%Y%m%d%H%M%S")
508 timestamp.strftime("%Y%m%d%H%M%S")
506 ]
509 ]
507 if rand
510 if rand
508 hash << Redmine::Utils.random_hex(8)
511 hash << Redmine::Utils.random_hex(8)
509 end
512 end
510 host = Setting.mail_from.to_s.strip.gsub(%r{^.*@|>}, '')
513 host = Setting.mail_from.to_s.strip.gsub(%r{^.*@|>}, '')
511 host = "#{::Socket.gethostname}.redmine" if host.empty?
514 host = "#{::Socket.gethostname}.redmine" if host.empty?
512 "#{hash.join('.')}@#{host}"
515 "#{hash.join('.')}@#{host}"
513 end
516 end
514
517
515 # Returns a Message-Id for the given object
518 # Returns a Message-Id for the given object
516 def self.message_id_for(object)
519 def self.message_id_for(object)
517 token_for(object, true)
520 token_for(object, true)
518 end
521 end
519
522
520 # Returns a uniq token for a given object referenced by all notifications
523 # Returns a uniq token for a given object referenced by all notifications
521 # related to this object
524 # related to this object
522 def self.references_for(object)
525 def self.references_for(object)
523 token_for(object, false)
526 token_for(object, false)
524 end
527 end
525
528
526 def message_id(object)
529 def message_id(object)
527 @message_id_object = object
530 @message_id_object = object
528 end
531 end
529
532
530 def references(object)
533 def references(object)
531 @references_objects ||= []
534 @references_objects ||= []
532 @references_objects << object
535 @references_objects << object
533 end
536 end
534
537
535 def mylogger
538 def mylogger
536 Rails.logger
539 Rails.logger
537 end
540 end
538 end
541 end
General Comments 0
You need to be logged in to leave comments. Login now