Extend the watcher functionality to send email notifications for issues
Added by Maxime Corbeau about 14 years ago
Hi there,
We would like to extend the functionality of the 'Watch' & 'Unwatch' buttons so that:
-when someone clicks on the 'Watch' button for an issue the assignee of that issue receives an email notification
-when someone clicks on 'Unwatch' the button switches back to 'Watch' as normal
The reason we want this is to use Redmine in an IT helpdesk environment, allowing users to search and subscribe to issues themselves so that IT can be notified automatically.
We tried to create a new mail function in app/models/mailer.rb to send an email to the issue assignee
# send email to issue assignee when someone watches the issue def issue_newwatcher(issue) if issue.assigned_to redmine_headers 'Project' => issue.project.identifier, 'Issue-Id' => issue.id, message_id issue recipients issue.assigned_to.mail subject "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] Someone is experiencing this issue" body :issue => issue, :issue_url => url_for(:controller => 'issues', :action => 'show', :id => issue) render_multipart('issue_newwatcher', body) end end
-Then we linked the mail function to the watcher controller in app/controllers/watchers_controller.rb
def watch if @watched.respond_to?(:visible?) && !@watched.visible?(User.current) render_403 else Mailer.deliver_issue_newwatcher(issue) set_watcher(User.current, true) end end
-However the watcher button is complete broken now (it doesn't switch between 'watch' or 'unwatch' and doesn't send an email either) so we know we're modifying the right files but just don't know how to integrate it properly.
Any assistance would be welcome.
Replies (2)
RE: Extend the watcher functionality to send email notifications for issues
-
Added by Felix Schäfer about 14 years ago
You will probably need to define a views for the email in app/views/mailer/issue_newwatcher.text.html.erb
and app/views/mailer/issue_newwatcher.text.plain.erb
.
RE: Extend the watcher functionality to send email notifications for issues
-
Added by Rob van den Bogaard about 13 years ago
It trips over the issue variable (used as parameter to deliver_issue_newwatcher) not being set.