This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Returns the mail adresses of users that should be notified | |
def recipients | |
notified = project.notified_users | |
# Author and assignee are always notified unless they have been locked | |
notified << author if author && author.active? && author.notify_about?(self) | |
notified << entered_by if entered_by && entered_by.active? && entered_by.notify_about?(self) | |
notified << assigned_to if assigned_to && assigned_to.active? && assigned_to.notify_about?(self) | |
notified.uniq! | |
# Remove users that can not view the issue | |
notified.reject! {|user| !visible?(user)} | |
notified.collect(&:mail) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Utility method to help check if a user should be notified about an | |
# event. | |
# | |
# TODO: only supports Issue events currently | |
def notify_about?(object) | |
case mail_notification.to_sym | |
when :all | |
true | |
when :selected | |
# Handled by the Project | |
when :none | |
false | |
when :only_my_events | |
if object.is_a?(Issue)&& (object.author == self || object.entered_by ==self || object.assigned_to == self) | |
true | |
else | |
false | |
end | |
when :only_assigned | |
if object.is_a?(Issue) && object.assigned_to == self | |
true | |
else | |
false | |
end | |
when :only_owner | |
if object.is_a?(Issue) && object.author == self | |
true | |
else | |
false | |
end | |
when :only_owner_or_creator | |
if object.is_a?(Issue) && (object.author == self || object.entered_by == self) | |
true | |
else | |
false | |
end | |
else | |
false | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment