summaryrefslogtreecommitdiff
path: root/app/models/note.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dzaporozhets@sphereconsultinginc.com>2012-02-10 10:59:39 +0800
committerDmitriy Zaporozhets <dzaporozhets@sphereconsultinginc.com>2012-02-10 10:59:39 +0800
commita769204ff489bc750c4931ecdb22ef055eac042a (patch)
tree467e0e76f8c79ecb85d9bfe18bfe63610e767af0 /app/models/note.rb
parentadcfeae1614e208a960ab99ba817380856563435 (diff)
downloadgitlab-ce-a769204ff489bc750c4931ecdb22ef055eac042a.tar.gz
Improved commit author notification
Diffstat (limited to 'app/models/note.rb')
-rw-r--r--app/models/note.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/app/models/note.rb b/app/models/note.rb
index 01a550708cb..581f78335cf 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -57,6 +57,36 @@ class Note < ActiveRecord::Base
rescue
nil
end
+
+ # Check if we can notify commit author
+ # with email about our comment
+ #
+ # If commit author email exist in project
+ # and commit author is not passed user we can
+ # send email to him
+ #
+ # params:
+ # user - current user
+ #
+ # return:
+ # Boolean
+ #
+ def notify_only_author?(user)
+ commit? && commit_author &&
+ commit_author.email != user.email
+ end
+
+ def commit?
+ noteable_type == "Commit"
+ end
+
+ def commit_author
+ @commit_author ||=
+ project.users.find_by_email(target.author_email) ||
+ project.users.find_by_name(target.author_name)
+ rescue
+ nil
+ end
end
# == Schema Information
#