comparison app/models/mailer.rb @ 1517:dffacf8a6908 redmine-2.5

Update to Redmine SVN revision 13367 on 2.5-stable branch
author Chris Cannam
date Tue, 09 Sep 2014 09:29:00 +0100
parents e248c7af89ec
children a1bdbf8a87d5
comparison
equal deleted inserted replaced
1516:b450a9d58aed 1517:dffacf8a6908
78 78
79 # Notifies users about an issue update 79 # Notifies users about an issue update
80 def self.deliver_issue_edit(journal) 80 def self.deliver_issue_edit(journal)
81 issue = journal.journalized.reload 81 issue = journal.journalized.reload
82 to = journal.notified_users 82 to = journal.notified_users
83 cc = journal.notified_watchers 83 cc = journal.notified_watchers - to
84 journal.each_notification(to + cc) do |users| 84 journal.each_notification(to + cc) do |users|
85 issue.each_notification(users) do |users2| 85 issue.each_notification(users) do |users2|
86 Mailer.issue_edit(journal, to & users2, cc & users2).deliver 86 Mailer.issue_edit(journal, to & users2, cc & users2).deliver
87 end 87 end
88 end 88 end
156 message_id news 156 message_id news
157 references news 157 references news
158 @news = news 158 @news = news
159 @news_url = url_for(:controller => 'news', :action => 'show', :id => news) 159 @news_url = url_for(:controller => 'news', :action => 'show', :id => news)
160 mail :to => news.recipients, 160 mail :to => news.recipients,
161 :cc => news.cc_for_added_news,
161 :subject => "[#{news.project.name}] #{l(:label_news)}: #{news.title}" 162 :subject => "[#{news.project.name}] #{l(:label_news)}: #{news.title}"
162 end 163 end
163 164
164 # Builds a Mail::Message object used to email recipients of a news' project when a news comment is added. 165 # Builds a Mail::Message object used to email recipients of a news' project when a news comment is added.
165 # 166 #
264 # Example: 265 # Example:
265 # account_activation_request(user) => Mail::Message object 266 # account_activation_request(user) => Mail::Message object
266 # Mailer.account_activation_request(user).deliver => sends an email to all active administrators 267 # Mailer.account_activation_request(user).deliver => sends an email to all active administrators
267 def account_activation_request(user) 268 def account_activation_request(user)
268 # Send the email to all active administrators 269 # Send the email to all active administrators
269 recipients = User.active.where(:admin => true).all.collect { |u| u.mail }.compact 270 recipients = User.active.where(:admin => true).collect { |u| u.mail }.compact
270 @user = user 271 @user = user
271 @url = url_for(:controller => 'users', :action => 'index', 272 @url = url_for(:controller => 'users', :action => 'index',
272 :status => User::STATUS_REGISTERED, 273 :status => User::STATUS_REGISTERED,
273 :sort_key => 'created_on', :sort_order => 'desc') 274 :sort_key => 'created_on', :sort_order => 'desc')
274 mail :to => recipients, 275 mail :to => recipients,
328 " AND #{Issue.table_name}.due_date <= ?", days.day.from_now.to_date 329 " AND #{Issue.table_name}.due_date <= ?", days.day.from_now.to_date
329 ) 330 )
330 scope = scope.where(:assigned_to_id => user_ids) if user_ids.present? 331 scope = scope.where(:assigned_to_id => user_ids) if user_ids.present?
331 scope = scope.where(:project_id => project.id) if project 332 scope = scope.where(:project_id => project.id) if project
332 scope = scope.where(:tracker_id => tracker.id) if tracker 333 scope = scope.where(:tracker_id => tracker.id) if tracker
333 334 issues_by_assignee = scope.includes(:status, :assigned_to, :project, :tracker).
334 issues_by_assignee = scope.includes(:status, :assigned_to, :project, :tracker).all.group_by(&:assigned_to) 335 group_by(&:assigned_to)
335 issues_by_assignee.keys.each do |assignee| 336 issues_by_assignee.keys.each do |assignee|
336 if assignee.is_a?(Group) 337 if assignee.is_a?(Group)
337 assignee.users.each do |user| 338 assignee.users.each do |user|
338 issues_by_assignee[user] ||= [] 339 issues_by_assignee[user] ||= []
339 issues_by_assignee[user] += issues_by_assignee[assignee] 340 issues_by_assignee[user] += issues_by_assignee[assignee]
461 timestamp.strftime("%Y%m%d%H%M%S") 462 timestamp.strftime("%Y%m%d%H%M%S")
462 ] 463 ]
463 if rand 464 if rand
464 hash << Redmine::Utils.random_hex(8) 465 hash << Redmine::Utils.random_hex(8)
465 end 466 end
466 host = Setting.mail_from.to_s.gsub(%r{^.*@}, '') 467 host = Setting.mail_from.to_s.strip.gsub(%r{^.*@|>}, '')
467 host = "#{::Socket.gethostname}.redmine" if host.empty? 468 host = "#{::Socket.gethostname}.redmine" if host.empty?
468 "#{hash.join('.')}@#{host}" 469 "#{hash.join('.')}@#{host}"
469 end 470 end
470 471
471 # Returns a Message-Id for the given object 472 # Returns a Message-Id for the given object