# Returns the mail adresses of users that should be notified for the issue
def recipients
recipients = project.recipients
- # Author and assignee are always notified
- recipients << author.mail if author
- recipients << assigned_to.mail if assigned_to
+ # Author and assignee are always notified unless they have been locked
+ recipients << author.mail if author && author.active?
+ recipients << assigned_to.mail if assigned_to && assigned_to.active?
recipients.compact.uniq
end
class MessageObserver < ActiveRecord::Observer
def after_create(message)
# send notification to the authors of the thread
- recipients = ([message.root] + message.root.children).collect {|m| m.author.mail if m.author}
+ recipients = ([message.root] + message.root.children).collect {|m| m.author.mail if m.author && m.author.active?}
# send notification to the board watchers
recipients += message.board.watcher_recipients
recipients = recipients.compact.uniq
end
def watcher_recipients
- self.watchers.collect { |w| w.user.mail }
+ self.watchers.collect { |w| w.user.mail if w.user.active? }.compact
end
module ClassMethods