@@ -98,6 +98,7 class Mailer < ActionMailer::Base | |||||
98 | def document_added(document) |
|
98 | def document_added(document) | |
99 | redmine_headers 'Project' => document.project.identifier |
|
99 | redmine_headers 'Project' => document.project.identifier | |
100 | recipients document.recipients |
|
100 | recipients document.recipients | |
|
101 | @author = User.current | |||
101 | subject "[#{document.project.name}] #{l(:label_document_new)}: #{document.title}" |
|
102 | subject "[#{document.project.name}] #{l(:label_document_new)}: #{document.title}" | |
102 | body :document => document, |
|
103 | body :document => document, | |
103 | :document_url => url_for(:controller => 'documents', :action => 'show', :id => document) |
|
104 | :document_url => url_for(:controller => 'documents', :action => 'show', :id => document) | |
@@ -113,6 +114,7 class Mailer < ActionMailer::Base | |||||
113 | container = attachments.first.container |
|
114 | container = attachments.first.container | |
114 | added_to = '' |
|
115 | added_to = '' | |
115 | added_to_url = '' |
|
116 | added_to_url = '' | |
|
117 | @author = attachments.first.author | |||
116 | case container.class.name |
|
118 | case container.class.name | |
117 | when 'Project' |
|
119 | when 'Project' | |
118 | added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container) |
|
120 | added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container) | |
@@ -142,6 +144,7 class Mailer < ActionMailer::Base | |||||
142 | # Mailer.deliver_news_added(news) => sends an email to the news' project recipients |
|
144 | # Mailer.deliver_news_added(news) => sends an email to the news' project recipients | |
143 | def news_added(news) |
|
145 | def news_added(news) | |
144 | redmine_headers 'Project' => news.project.identifier |
|
146 | redmine_headers 'Project' => news.project.identifier | |
|
147 | @author = news.author | |||
145 | message_id news |
|
148 | message_id news | |
146 | recipients news.recipients |
|
149 | recipients news.recipients | |
147 | subject "[#{news.project.name}] #{l(:label_news)}: #{news.title}" |
|
150 | subject "[#{news.project.name}] #{l(:label_news)}: #{news.title}" | |
@@ -158,6 +161,7 class Mailer < ActionMailer::Base | |||||
158 | def news_comment_added(comment) |
|
161 | def news_comment_added(comment) | |
159 | news = comment.commented |
|
162 | news = comment.commented | |
160 | redmine_headers 'Project' => news.project.identifier |
|
163 | redmine_headers 'Project' => news.project.identifier | |
|
164 | @author = comment.author | |||
161 | message_id comment |
|
165 | message_id comment | |
162 | recipients news.recipients |
|
166 | recipients news.recipients | |
163 | cc news.watcher_recipients |
|
167 | cc news.watcher_recipients | |
@@ -176,6 +180,7 class Mailer < ActionMailer::Base | |||||
176 | def message_posted(message) |
|
180 | def message_posted(message) | |
177 | redmine_headers 'Project' => message.project.identifier, |
|
181 | redmine_headers 'Project' => message.project.identifier, | |
178 | 'Topic-Id' => (message.parent_id || message.id) |
|
182 | 'Topic-Id' => (message.parent_id || message.id) | |
|
183 | @author = message.author | |||
179 | message_id message |
|
184 | message_id message | |
180 | references message.parent unless message.parent.nil? |
|
185 | references message.parent unless message.parent.nil? | |
181 | recipients(message.recipients) |
|
186 | recipients(message.recipients) | |
@@ -194,6 +199,7 class Mailer < ActionMailer::Base | |||||
194 | def wiki_content_added(wiki_content) |
|
199 | def wiki_content_added(wiki_content) | |
195 | redmine_headers 'Project' => wiki_content.project.identifier, |
|
200 | redmine_headers 'Project' => wiki_content.project.identifier, | |
196 | 'Wiki-Page-Id' => wiki_content.page.id |
|
201 | 'Wiki-Page-Id' => wiki_content.page.id | |
|
202 | @author = wiki_content.author | |||
197 | message_id wiki_content |
|
203 | message_id wiki_content | |
198 | recipients wiki_content.recipients |
|
204 | recipients wiki_content.recipients | |
199 | cc(wiki_content.page.wiki.watcher_recipients - recipients) |
|
205 | cc(wiki_content.page.wiki.watcher_recipients - recipients) | |
@@ -213,6 +219,7 class Mailer < ActionMailer::Base | |||||
213 | def wiki_content_updated(wiki_content) |
|
219 | def wiki_content_updated(wiki_content) | |
214 | redmine_headers 'Project' => wiki_content.project.identifier, |
|
220 | redmine_headers 'Project' => wiki_content.project.identifier, | |
215 | 'Wiki-Page-Id' => wiki_content.page.id |
|
221 | 'Wiki-Page-Id' => wiki_content.page.id | |
|
222 | @author = wiki_content.author | |||
216 | message_id wiki_content |
|
223 | message_id wiki_content | |
217 | recipients wiki_content.recipients |
|
224 | recipients wiki_content.recipients | |
218 | cc(wiki_content.page.wiki.watcher_recipients + wiki_content.page.watcher_recipients - recipients) |
|
225 | cc(wiki_content.page.wiki.watcher_recipients + wiki_content.page.watcher_recipients - recipients) | |
@@ -387,15 +394,18 class Mailer < ActionMailer::Base | |||||
387 |
|
394 | |||
388 | # Overrides the create_mail method |
|
395 | # Overrides the create_mail method | |
389 | def create_mail |
|
396 | def create_mail | |
390 |
# Removes the |
|
397 | # Removes the author from the recipients and cc | |
391 | # if he doesn't want to receive notifications about what he does |
|
398 | # if he doesn't want to receive notifications about what he does | |
392 | @author ||= User.current |
|
399 | if @author && @author.logged? && @author.pref[:no_self_notified] | |
393 | if @author.pref[:no_self_notified] |
|
400 | if recipients | |
394 | recipients.delete(@author.mail) if recipients |
|
401 | recipients((recipients.is_a?(Array) ? recipients : [recipients]) - [@author.mail]) | |
395 | cc.delete(@author.mail) if cc |
|
402 | end | |
|
403 | if cc | |||
|
404 | cc((cc.is_a?(Array) ? cc : [cc]) - [@author.mail]) | |||
|
405 | end | |||
396 | end |
|
406 | end | |
397 |
|
407 | |||
398 | if @author.logged? |
|
408 | if @author && @author.logged? | |
399 | redmine_headers 'Sender' => @author.login |
|
409 | redmine_headers 'Sender' => @author.login | |
400 | end |
|
410 | end | |
401 |
|
411 |
@@ -84,6 +84,11 class AdminControllerTest < ActionController::TestCase | |||||
84 | end |
|
84 | end | |
85 |
|
85 | |||
86 | def test_test_email |
|
86 | def test_test_email | |
|
87 | user = User.find(1) | |||
|
88 | user.pref[:no_self_notified] = '1' | |||
|
89 | user.pref.save! | |||
|
90 | ActionMailer::Base.deliveries.clear | |||
|
91 | ||||
87 | get :test_email |
|
92 | get :test_email | |
88 | assert_redirected_to '/settings/edit?tab=notifications' |
|
93 | assert_redirected_to '/settings/edit?tab=notifications' | |
89 | mail = ActionMailer::Base.deliveries.last |
|
94 | mail = ActionMailer::Base.deliveries.last |
General Comments 0
You need to be logged in to leave comments.
Login now