Commit 53ce00f7 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #231 from CedricGatay/feature/commit_author_mail_for_note

Alert only commit author on note
parents bac0fa2c c0b47d32
...@@ -13,6 +13,7 @@ class NotesController < ApplicationController ...@@ -13,6 +13,7 @@ class NotesController < ApplicationController
@note = @project.notes.new(params[:note]) @note = @project.notes.new(params[:note])
@note.author = current_user @note.author = current_user
@note.notify = true if params[:notify] == '1' @note.notify = true if params[:notify] == '1'
@note.notify_author = true if params[:notify_author] == '1'
@note.save @note.save
respond_to do |format| respond_to do |format|
......
...@@ -28,6 +28,7 @@ class Notify < ActionMailer::Base ...@@ -28,6 +28,7 @@ class Notify < ActionMailer::Base
@note = note @note = note
@project = note.project @project = note.project
@commit = @project.repo.commits(note.noteable_id).first @commit = @project.repo.commits(note.noteable_id).first
return unless ( note.notify or ( note.notify_author and @commit.author.email == @user.email ) )
mail(:to => @user.email, :subject => "gitlab | #{@note.project.name} ") mail(:to => @user.email, :subject => "gitlab | #{@note.project.name} ")
end end
......
...@@ -27,7 +27,7 @@ class MailerObserver < ActiveRecord::Observer ...@@ -27,7 +27,7 @@ class MailerObserver < ActiveRecord::Observer
end end
def new_note(note) def new_note(note)
return unless note.notify return unless note.notify or note.notify_author
note.project.users.reject { |u| u.id == current_user.id } .each do |u| note.project.users.reject { |u| u.id == current_user.id } .each do |u|
case note.noteable_type case note.noteable_type
when "Commit" then when "Commit" then
......
...@@ -14,6 +14,7 @@ class Note < ActiveRecord::Base ...@@ -14,6 +14,7 @@ class Note < ActiveRecord::Base
attr_protected :author, :author_id attr_protected :author, :author_id
attr_accessor :notify attr_accessor :notify
attr_accessor :notify_author
validates_presence_of :project validates_presence_of :project
...@@ -40,6 +41,10 @@ class Note < ActiveRecord::Base ...@@ -40,6 +41,10 @@ class Note < ActiveRecord::Base
def notify def notify
@notify ||= false @notify ||= false
end end
def notify_author
@notify_author ||= false
end
end end
# == Schema Information # == Schema Information
# #
......
...@@ -23,9 +23,13 @@ ...@@ -23,9 +23,13 @@
%br %br
= f.file_field :attachment = f.file_field :attachment
= check_box_tag :notify, 1, true = check_box_tag :notify, 1, @note.noteable_type != "Commit"
= label_tag :notify, "Notify project team about your note" = label_tag :notify, "Notify project team about your note"
-if @note.noteable_type == "Commit"
= check_box_tag :notify_author, 1 , @note.noteable_type == "Commit"
= label_tag :notify_author, "Notify commit author about your note"
.clear .clear
%br %br
= f.submit 'Add note', :class => "grey-button", :id => "submit_note" = f.submit 'Add note', :class => "grey-button", :id => "submit_note"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment