Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorRiyad Preukschas <riyad@informatik.uni-bremen.de>2012-10-14 00:46:27 +0400
committerRiyad Preukschas <riyad@informatik.uni-bremen.de>2012-10-18 03:14:10 +0400
commit413778b6458c71706685150f191becee5d398391 (patch)
treee581bdc8baae3d1464d8f4f1920fb07a38fdd51b /app
parent853c69c48a1641ad742cf9f70326fc93c44ea58d (diff)
Rename NoteObserver methods and clarify things
Diffstat (limited to 'app')
-rw-r--r--app/observers/note_observer.rb21
1 files changed, 13 insertions, 8 deletions
diff --git a/app/observers/note_observer.rb b/app/observers/note_observer.rb
index d328338a706..083aa7058d5 100644
--- a/app/observers/note_observer.rb
+++ b/app/observers/note_observer.rb
@@ -1,9 +1,14 @@
class NoteObserver < ActiveRecord::Observer
def after_create(note)
+ send_notify_mails(note)
+ end
+
+ protected
+
+ def send_notify_mails(note)
if note.notify
- # Notify whole team except author of note
- notify_team_of_new_note(note)
+ notify_team(note)
elsif note.notify_author
# Notify only author of resource
Notify.note_commit_email(note.commit_author.id, note.id).deliver
@@ -13,15 +18,15 @@ class NoteObserver < ActiveRecord::Observer
end
end
- protected
-
- def notify_team_of_new_note(note)
- note_is_on = note.noteable_type || 'Wall'
- notify_method = 'note_' + note_is_on.underscore + '_email'
+ # Notifies the whole team except the author of note
+ def notify_team(note)
+ # Note: wall posts are not "attached" to anything, so fall back to "Wall"
+ noteable_type = note.noteable_type || "Wall"
+ notify_method = "note_#{noteable_type.underscore}_email".to_sym
if Notify.respond_to? notify_method
team_without_note_author(note).map do |u|
- Notify.send(notify_method.to_sym, u.id, note.id).deliver
+ Notify.send(notify_method, u.id, note.id).deliver
end
end
end