プロジェクト

全般

プロフィール

Vote #77614

完了

When creating issues by receiving an email, watchers created via CC in the mail don't get an email notification

Admin Redmine さんが4年以上前に追加. 4年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Email receiving_29
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
29
version_id:
121
issue_org_id:
23278
author_id:
2784
assigned_to_id:
1
comments:
8
status_id:
5
tracker_id:
3
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

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":https://plan.io/redmine-hosting, we use the attached patch to fix this behaviour and send the initial notifications to all watcher users on issue creation.


journals

Yes, we can see that by removing @issue.reload@ in @MailHandlerTest#test_add_issue_should_add_cc_as_watchers@.
I've committed a different fix in r15609 that uses @#reset@ instead of @#reload@ in @#add_watcher@ and @#remove_watcher@ instead of forcing a reload before sending the notification.
Please let me know if there is anything wrong with that.
--------------------------------------------------------------------------------
Using @reset@ instead of @reload@ should result in the exactly the same result since Rails will then autoload the association on next access anyway. Using @reset@ will just be a bit faster if we haven't updated the association since we are saving some SQL queries. Thus, a big +1 from me. Thanks, Jean-Philippe!
--------------------------------------------------------------------------------
Thanks for your feedback Holger, I've merged the fix.
--------------------------------------------------------------------------------
Jean-Philippe Lang wrote:
> Thanks for your feedback Holger, I've merged the fix.

Hi,
reset shoundn't happen after add/remove?
--------------------------------------------------------------------------------
Victor Campos wrote:
> reset shoundn't happen after add/remove?

The "reset":http://api.rubyonrails.org/classes/ActiveRecord/Associations/CollectionProxy.html#method-i-reset method just clear the cache of the association proxy but does not actually reload the association. As such, the only requirement is that the reset happens before the @watcher_users@ association is accessed next time. This does not happen when adding the watcher itself. As such, resetting the association before adding the watcher is fine.
--------------------------------------------------------------------------------
Holger Just wrote:
> Victor Campos wrote:
> > reset shoundn't happen after add/remove?
>
> The "reset":http://api.rubyonrails.org/classes/ActiveRecord/Associations/CollectionProxy.html#method-i-reset method just clear the cache of the association proxy but does not actually reload the association. As such, the only requirement is that the reset happens before the @watcher_users@ association is accessed next time. This does not happen when adding the watcher itself. As such, resetting the association before adding the watcher is fine.

Thx =)

--------------------------------------------------------------------------------
Does this in any way change the handling of watchers not being added from the FROM: field of an email-imported issue?
--------------------------------------------------------------------------------
Joaquim Homrighausen wrote:
> Does this in any way change the handling of watchers not being added from the FROM: field of an email-imported issue?

AFAIK, FROM become author.
If you mean CC not FROM, please create new feature issue.

--------------------------------------------------------------------------------

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0