diff options
Diffstat (limited to 'app/models/user.rb')
-rw-r--r-- | app/models/user.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 9fe5ff2ab..281e71281 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -368,6 +368,41 @@ class User < Principal allowed_to?(action, nil, options.reverse_merge(:global => true)) end + # 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.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 + else + false + end + end + def self.current=(user) @current_user = user end |