Vote #64582
完了Refactor Mailer delivery methods out of controller and into observers
100%
説明
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.
--------------------------------------------------------------------------------