Project

General

Profile

Actions

Patch #44681

open

Extract the auto watch logic shared by Issue and Journal into a concern

Added by Marius BĂLTEANU about 22 hours ago. Updated about 8 hours ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Code cleanup/refactoring
Target version:

Description

The rule for automatically adding a user as a watcher of an issue is currently implemented twice:
  • Issue#add_auto_watcher for issue_created and, since #44680, issue_assigned_to_me on issue creation
  • Journal#add_watcher and Journal#valid_watcher? for issue_contributed_to and issue_assigned_to_me on issue update

Both copies check the same conditions (the user is active, has the option enabled, has the "Add watchers" permission, can see the issue, and is not already watching it directly or through a group).

The attached patch moves this rule into a new Issue::AutoWatchable concern, following the existing Issue::Webhookable concern:
  • Issue#auto_watch(user, option) adds the user as a watcher if the given auto watch option is enabled and the user is allowed to watch the issue
  • Issue#add_auto_watcher (creation callback) and Journal#add_watcher (update callback) both call it

Files


Related issues

Related to Redmine - Defect #44680: Assignee is not added as a watcher when creating an issue with an assignee who has auto-watch for assigned issues enabledResolvedMarius BĂLTEANUActions
Related to Redmine - Feature #43673: Allow auto-watching issues assigned to my groupsNewActions
Related to Redmine - Feature #2716: User option to automatically add assignee to watchersClosedMarius BĂLTEANUActions
Actions #2

Updated by Marius BĂLTEANU about 13 hours ago

  • Related to Defect #44680: Assignee is not added as a watcher when creating an issue with an assignee who has auto-watch for assigned issues enabled added
Actions #3

Updated by Marius BĂLTEANU about 13 hours ago

  • Related to Feature #43673: Allow auto-watching issues assigned to my groups added
Actions #4

Updated by Marius BĂLTEANU about 13 hours ago

  • Related to Feature #2716: User option to automatically add assignee to watchers added
Actions #5

Updated by Ivan Kabluchkov about 8 hours ago

I think that checking of permission during "system" actions is not proper way. Because if user has setting auto watch "Issue assigned to me" option and role permission "Add watchers" turned off, than he never be added as watcher to issue. This behaviour can make user confused
The same Florian wrote here https://www.redmine.org/issues/44680#note-1

Actions

Also available in: Atom PDF