Index: app/models/journal_observer.rb =================================================================== --- app/models/journal_observer.rb (revision 2824) +++ app/models/journal_observer.rb (working copy) @@ -17,6 +17,12 @@ class JournalObserver < ActiveRecord::Observer def after_create(journal) - Mailer.deliver_issue_edit(journal) if Setting.notified_events.include?('issue_updated') + case(journal.journalized_type) + when 'Issue': + Mailer.deliver_issue_edit(journal) if Setting.notified_events.include?('issue_updated') + when 'ChangeSet': + # notifty revision commiter + Mailer.deliver_changeset_comment(journal) if Setting.notified_events.include?('revision_comment_added') + end end end Index: app/models/mailer.rb =================================================================== --- app/models/mailer.rb (revision 2824) +++ app/models/mailer.rb (working copy) @@ -72,6 +72,20 @@ :journal => journal, :issue_url => url_for(:controller => 'issues', :action => 'show', :id => issue) end + + def changeset_comment(journal) + changeset = journal.journalized.reload + redmine_headers 'Project' => changeset.repository.project.identifier, + 'Revision' => changeset.revision + message_id journal + references changeset + @author = journal.user + recipients changeset.recipients + subject "[#{changeset.repository.project.name}] #{l(:label_revision)} #{changeset.revision}" + body :changeset => changeset, + :journal => journal, + :changeset_url => url_for(:controller => 'projects') + "/#{changeset.repository.project.identifier}/repository/revisions/#{changeset.revision}" + end def reminder(user, issues, days) set_language_if_valid user.language Index: app/models/changeset.rb =================================================================== --- app/models/changeset.rb (revision 2824) +++ app/models/changeset.rb (working copy) @@ -21,6 +21,7 @@ belongs_to :repository belongs_to :user has_many :changes, :dependent => :delete_all + has_many :journals, :as => :journalized, :dependent => :destroy has_and_belongs_to_many :issues acts_as_event :title => Proc.new {|o| "#{l(:label_revision)} #{o.revision}" + (o.short_comments.blank? ? '' : (': ' + o.short_comments))}, @@ -146,6 +147,19 @@ to_utf8(str.to_s.strip) end + # Returns the mail adresses of users that should be notified for the changeset + # Includes: project recipients, the revision commiter, and other users who have commented + def recipients + recipients = repository.project.recipients + recipients << user.mail if user && user.active? # committer + recipients << journals.collect { |j| j.user.mail if j.user } # other commenters + recipients.compact.uniq + end + + def created_on + self.committed_on + end + private def split_comments Index: app/controllers/repositories_controller.rb =================================================================== --- app/controllers/repositories_controller.rb (revision 2824) +++ app/controllers/repositories_controller.rb (working copy) @@ -137,7 +137,12 @@ def revision @changeset = @repository.changesets.find_by_revision(@rev) raise ChangesetNotFound unless @changeset + @journal = @changeset.journals.new + @journals = @changeset.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC") + @journals.each_with_index {|j,i| j.indice = i+1} + @journals.reverse! if User.current.wants_comments_in_reverse_order? + respond_to do |format| format.html format.js {render :layout => false} @@ -146,6 +151,20 @@ show_error_not_found end + def add_journal + @changeset = @repository.changesets.find_by_revision(@rev) + @journal = @changeset.journals.new(params[:journal]) + @journal.user = User.current + + respond_to do |format| + if @journal.save + format.html { redirect_to :action => :revision } + else + format.html { redirect_to :action => :revision } + end + end + end + def diff if params[:format] == 'diff' @diff = @repository.diff(@path, @rev, @rev_to) Index: app/views/mailer/changeset_comment.text.plain.rhtml =================================================================== --- app/views/mailer/changeset_comment.text.plain.rhtml (revision 0) +++ app/views/mailer/changeset_comment.text.plain.rhtml (revision 0) @@ -0,0 +1,5 @@ +<%= l(:text_changeset_commented, :rev => "##{@changeset.revision}", :author => @journal.user) %> + +<%= @journal.notes %> + +<%= @changeset_url %> Index: app/views/mailer/changeset_comment.text.html.rhtml =================================================================== --- app/views/mailer/changeset_comment.text.html.rhtml (revision 0) +++ app/views/mailer/changeset_comment.text.html.rhtml (revision 0) @@ -0,0 +1,5 @@ +<%= l(:text_changeset_commented, :rev => "##{@changeset.revision}", :author => @journal.user) %> + +<%= textilizable(@journal, :notes, :only_path => false) %> + +