Patch #23278
closedWhen creating issues by receiving an email, watchers created via CC in the mail don't get an email notification
0%
Description
When creating issues by email via the redmine:email:*
rake tasks, users mentioned in the CC field of the email get added as watchers to the created issue. However, these watchers don't get a notification mail about the creation of the new issue.
The reason for that is rather complex and doves deep into the ActiveRecord bowels. To make things short, the list of recipients for a notification mail is gathered by acts_as_watchable
from the watcher_users attribute which is defined as
has_many :watcher_users, :through => :watchers, :source => :user, :validate => false
Now, when adding new watchers to an existing object (as is done in MailHandler#add_watchers
, resp. Redmine::Acts::Watchable#add_watcher
, the cache of the watcher_users
relation which is maintained by Rails is not updated. As such, when querying @issue.watchers
, you get the correct list of watchers but @issue.watcher_users
still reflects the state before the watchers were added.
Thus, while the watchers get added correctly to the database, they will be ignored during the actual mail receive action and will thus not receive any initial notification.
At Planio, we use the attached patch to fix this behaviour and send the initial notifications to all watcher users on issue creation.
Files