Project

General

Profile

Actions

Feature #1446

closed

Allow notification on editing of a message

Added by Randy Harmon almost 16 years ago. Updated about 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Email notifications
Target version:
-
Start date:
2008-06-13
Due date:
% Done:

0%

Estimated time:
Resolution:
Duplicate

Description

There's no way to notify when a message is edited.


Related issues

Is duplicate of Redmine - Feature #12416: Comment change notificationNew

Actions
Actions #1

Updated by Randy Harmon almost 16 years ago

Index: app/controllers/settings_controller.rb
===================================================================
--- app/controllers/settings_controller.rb      (revision 1524)
+++ app/controllers/settings_controller.rb      (working copy)
@@ -25,7 +25,7 @@
   end

   def edit
-    @notifiables = %w(issue_added issue_updated news_added document_added file_added message_posted)
+    @notifiables = %w(issue_added issue_updated news_added document_added file_added message_posted message_edited)
     if request.post? && params[:settings] && params[:settings].is_a?(Hash)
       settings = (params[:settings] || {}).dup.symbolize_keys
       settings.each do |name, value|
Index: app/models/message_observer.rb
===================================================================
--- app/models/message_observer.rb      (revision 1524)
+++ app/models/message_observer.rb      (working copy)
@@ -17,6 +17,14 @@

 class MessageObserver < ActiveRecord::Observer
   def after_create(message)
+    send_for_event(message,'posted')
+  end
+
+  def after_save(message)
+    send_for_event(message,'edited')
+  end
+
+  def send_for_event(message,event)
     # send notification to the authors of the thread
     recipients = ([message.root] + message.root.children).collect {|m| m.author.mail if m.author && m.author.active?}
     # send notification to the board watchers
@@ -24,6 +32,6 @@
     # send notification to project members who want to be notified
     recipients += message.board.project.recipients
     recipients = recipients.compact.uniq
-    Mailer.deliver_message_posted(message, recipients) if !recipients.empty? && Setting.notified_events.include?('message_posted')
+    Mailer.deliver_message_posted(message, recipients) if !recipients.empty? && Setting.notified_events.include?("message_#{event}")
   end
 end
Index: test/functional/messages_controller_test.rb
===================================================================
--- test/functional/messages_controller_test.rb (revision 1524)
+++ test/functional/messages_controller_test.rb (working copy)
@@ -86,6 +86,8 @@

   def test_post_edit
     @request.session[:user_id] = 2
+    Setting.notified_events << 'message_edited'
+
     post :edit, :board_id => 1, :id => 1,
                 :message => { :subject => 'New subject',
                               :content => 'New body'}
@@ -93,6 +95,19 @@
     message = Message.find(1)
     assert_equal 'New subject', message.subject
     assert_equal 'New body', message.content
+
+
+
+
+    mail = ActionMailer::Base.deliveries.last
+    assert_kind_of TMail::Mail, mail
+    assert_equal "[#{message.board.project.name} - #{message.board.name}] New subject", mail.subject
+    assert mail.body.include?('New body')
+    # author
+    assert mail.bcc.include?('jsmith@somenet.foo')
+    # project member
+    assert mail.bcc.include?('dlopper@somenet.foo')
+
   end

   def test_reply
Actions #2

Updated by Jean-Philippe Lang almost 16 years ago

  • Target version deleted (0.7.2)
Actions #3

Updated by Toshi MARUYAMA almost 13 years ago

  • Category set to Issues
Actions #4

Updated by Александр Гужва about 12 years ago

  • File python.log added
Actions #5

Updated by Go MAEDA over 7 years ago

  • Category changed from Issues to Email notifications
Actions #6

Updated by Go MAEDA about 5 years ago

  • Tracker changed from Patch to Feature
Actions #7

Updated by Go MAEDA about 5 years ago

  • File deleted (python.log)
Actions #8

Updated by Go MAEDA about 5 years ago

Actions #9

Updated by Go MAEDA about 5 years ago

  • Resolution set to Duplicate

Closing as a duplicate of #12416.

Actions #10

Updated by Go MAEDA about 5 years ago

  • Status changed from New to Closed
Actions

Also available in: Atom PDF