diff options
author | Marius Balteanu <marius.balteanu@zitec.com> | 2022-03-19 10:14:29 +0000 |
---|---|---|
committer | Marius Balteanu <marius.balteanu@zitec.com> | 2022-03-19 10:14:29 +0000 |
commit | e50190a82a5b6a066a3fadfdebf9df6e268719ad (patch) | |
tree | c49f3341b96612314a1f0e238102cce24f1aaaa7 /app/models/journal.rb | |
parent | 23874fa913c62f7da23f2d1fab6e5e1a445ae290 (diff) | |
download | redmine-e50190a82a5b6a066a3fadfdebf9df6e268719ad.tar.gz redmine-e50190a82a5b6a066a3fadfdebf9df6e268719ad.zip |
Automatically add the user to the watchers list after contributing to an issue (#4347). User can enable/disable this feature from My Account.
Patch by Takenori TAKAKI and Jens Krämer.
git-svn-id: http://svn.redmine.org/redmine/trunk@21469 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/journal.rb')
-rw-r--r-- | app/models/journal.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/models/journal.rb b/app/models/journal.rb index 3d1feb906..01d5debcd 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -60,6 +60,7 @@ class Journal < ActiveRecord::Base ) acts_as_mentionable :attributes => ['notes'] before_create :split_private_notes + before_create :add_watcher after_create_commit :send_notification scope :visible, (lambda do |*args| @@ -327,6 +328,15 @@ class Journal < ActiveRecord::Base true end + def add_watcher + if user && + user.allowed_to?(:add_issue_watchers, project) && + user.pref.auto_watch_on?('issue_contributed_to') && + !Watcher.any_watched?(Array.wrap(journalized), user) + journalized.set_watcher(user, true) + end + end + def send_notification if notify? && ( |