From 2d8ccf778d335b551c177fd3ae05433db36d1a3d Mon Sep 17 00:00:00 2001 From: Marius Balteanu Date: Wed, 14 Jan 2026 06:56:34 +0000 Subject: [PATCH] Add user option to auto-watch issues previously assigned to me (#2716). git-svn-id: https://svn.redmine.org/redmine/trunk@24312 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/journal.rb | 8 ++++++++ app/models/user_preference.rb | 2 +- config/locales/en.yml | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/models/journal.rb b/app/models/journal.rb index 12f2beec8..7aed1d226 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -354,6 +354,14 @@ class Journal < ApplicationRecord !Watcher.any_watched?(Array.wrap(journalized), user) journalized.set_watcher(user, true) end + + assignee = journalized.assigned_to + if assignee.is_a?(User) && assignee&.active? && + assignee.allowed_to?(:add_issue_watchers, project) && + assignee.pref.auto_watch_on?('issue_assigned_to_me') && + !Watcher.any_watched?(Array.wrap(journalized), assignee) + journalized.set_watcher(assignee, true) + end end def send_notification diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb index fc1c3829b..67937e201 100644 --- a/app/models/user_preference.rb +++ b/app/models/user_preference.rb @@ -44,7 +44,7 @@ class UserPreference < ApplicationRecord TEXTAREA_FONT_OPTIONS = ['monospace', 'proportional'] DEFAULT_TOOLBAR_LANGUAGE_OPTIONS = %w[c cpp csharp css diff go groovy html java javascript objc perl php python r ruby sass scala shell sql swift xml yaml] - AUTO_WATCH_ON_OPTIONS = %w[issue_created issue_contributed_to] + AUTO_WATCH_ON_OPTIONS = %w[issue_created issue_contributed_to issue_assigned_to_me] def initialize(attributes=nil, *args) super diff --git a/config/locales/en.yml b/config/locales/en.yml index 1e36d5044..40e1e826e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -996,6 +996,7 @@ en: label_auto_watch_on: Auto watch label_auto_watch_on_issue_created: Issues I created label_auto_watch_on_issue_contributed_to: Issues I contributed to + label_auto_watch_on_issue_assigned_to_me: Issues assigned to me label_preferences: Preferences label_chronological_order: In chronological order label_reverse_chronological_order: In reverse chronological order