Closed ebergu78 closed 2 years ago
watcher group users cannot open the issue (Issues visibility = created by or assigned by the user) Error 403 Instead if I add the user as a watcher then the user can open the issue
ok, I suppose I need to add some unit test for the scenario. Thanks
Ok, I confirm that in extended mode, when adding a group of members as watchers, the group members do not gain visibility to the issue as it happens when added individually.
It would be helpful if you could fix it soon. Thanks a lot
not so easy because act_as_watchable.watched_by? does not support group watching by itself
I am validating this patch
diff --git a/plugins/redmine_extended_watchers/lib/extended_watchers_issue_patch.rb b/plugins/redmin e_extended_watchers/lib/extended_watchers_issue_patch.rb index 2a982fff7..817390e5b 100644 --- a/plugins/redmine_extended_watchers/lib/extended_watchers_issue_patch.rb +++ b/plugins/redmine_extended_watchers/lib/extended_watchers_issue_patch.rb @@ -94,6 +94,15 @@ module ExtendedWatchersIssueClassPatch scope.to_a end end + + # Override the acts_as_watchable scope to report watchers through watchers groups + def watched_by(user) + if (user.is_a?(User)) + joins(:watcher_users).where("#{Watcher.table_name}.user_id IN (?)", user.groups.ids << user.id) + else + super(user) + end + end end @@ -136,6 +145,14 @@ module ExtendedWatchersIssueInstancePatch users end + def watched_by?(user) + if (user && user.is_a?(User)) + !!(self.watcher_user_ids.detect {|uid| (user.groups.ids << user.id).include? uid }) + else + super(user) + end + end + end
Fix deployed in release 4.2.2 (branches: 4.2 and master). Thanks
Hi!
Redmine 4.2.0 allows adding user groups as watchers for issues, but redmine_extended_watchers 4.2.0 (policy = Extended) doesn't extend the scope of issue visibility to group users.