プロジェクト

全般

プロフィール

Vote #64582

完了

Refactor Mailer delivery methods out of controller and into observers

Admin Redmine さんがほぼ2年前に追加. ほぼ2年前に更新.

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

100%

予定工数:
category_id:
9
version_id:
6
issue_org_id:
2659
author_id:
5
assigned_to_id:
5
comments:
4
status_id:
5
tracker_id:
2
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

There are a few @Mailer@ method calls buried inside of controllers that would be better off as "Observers":http://api.rubyonrails.com/classes/ActiveRecord/Observer.html (e.g. @IssuesController#add@). I'll do the refactoring, just wanted to open an issue so it appears in the release notes.


journals

Before doing the refactoring, here are a few thoughts:
* how to do a single notification when several objects are added/updated (just how it occurs today when adding several files at the same time)? A notification should be also added when bulk editing issues. Sending a notification for each modified issue would be insane and pretty slow.
* maybe one day, we'd like to display the name of the users that were notified (eg. in the flash message). How to retrieve it from the observer?
--------------------------------------------------------------------------------
Jean-Philippe Lang wrote:
> Before doing the refactoring, here are a few thoughts:
> * how to do a single notification when several objects are added/updated (just how it occurs today when adding several files at the same time)?

I'll watch out for those. My main concern is the issue notifications. The @add_files@ action isn't very complex so it won't need refactoring right now.

> A notification should be also added when bulk editing issues. Sending a notification for each modified issue would be insane and pretty slow.

Bulk edits already send one email per issue:

<pre><code class="ruby"># app/controllers/issues_controller.rb L252
Mailer.deliver_issue_edit(journal) if journal.details.any? && Setting.notified_events.include?('issue_updated')
</code></pre>

> * maybe one day, we'd like to display the name of the users that were notified (eg. in the flash message). How to retrieve it from the observer?

Would that be the responsibility of the Observer, the Mailer, or the Controller though?
--------------------------------------------------------------------------------
I've added some observers to watch model objects for mail delivery instead of calling @Mailer@ in r2637.
--------------------------------------------------------------------------------
Thanks, I prefer to keep this refactoring for 0.9.
--------------------------------------------------------------------------------

Admin Redmine さんがほぼ2年前に更新

  • カテゴリEmail notifications_9 にセット
  • 対象バージョン0.9.0_6 にセット

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

いいね!0
いいね!0