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

Also available in: Atom PDF