Project

General

Profile

Actions

Patch #44681

open

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

Patch #44681: Extract the auto watch logic shared by Issue and Journal into a concern

Added by Marius BĂLTEANU 21 days ago. Updated 20 days 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 3 (1 open — 2 closed)

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 enabledClosedMarius 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

Updated by Marius BĂLTEANU 21 days ago Actions #2

  • 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

Updated by Marius BĂLTEANU 21 days ago Actions #3

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

Updated by Marius BĂLTEANU 21 days ago Actions #4

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

Updated by Ivan Kabluchkov 20 days ago Actions #5

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

Updated by Marius BĂLTEANU 20 days ago Actions #6

I agree, we should normalize the behaviour between the Watch button and this auto-watch in a separate issue.

Actions

Also available in: PDF Atom