Commit 4b5d3a0d63783c2067a1ccb8d2c515fc9278214f
1 parent
ba8148ef
Exists in
master
and in
1 other branch
Added email notifications for comments
Showing
6 changed files
with
107 additions
and
2 deletions
Show diff stats
app/mailers/mailer.rb
@@ -23,5 +23,15 @@ class Mailer < ActionMailer::Base | @@ -23,5 +23,15 @@ class Mailer < ActionMailer::Base | ||
23 | mail :to => @app.notification_recipients, | 23 | mail :to => @app.notification_recipients, |
24 | :subject => "[#{@app.name}] Deployed to #{@deploy.environment} by #{@deploy.username}" | 24 | :subject => "[#{@app.name}] Deployed to #{@deploy.environment} by #{@deploy.username}" |
25 | end | 25 | end |
26 | -end | ||
27 | 26 | ||
27 | + def comment_notification(comment) | ||
28 | + @comment = comment | ||
29 | + @user = comment.user | ||
30 | + @problem = comment.err | ||
31 | + @notice = @problem.notices.first | ||
32 | + @app = @problem.app | ||
33 | + | ||
34 | + mail :to => @app.notification_recipients, | ||
35 | + :subject => "#{@user.name} commented on [#{@app.name}][#{@notice.environment_name}] #{@notice.message.truncate(50)}" | ||
36 | + end | ||
37 | +end |
app/models/comment.rb
@@ -10,6 +10,7 @@ class Comment | @@ -10,6 +10,7 @@ class Comment | ||
10 | 10 | ||
11 | belongs_to :err, :class_name => "Problem" | 11 | belongs_to :err, :class_name => "Problem" |
12 | belongs_to :user | 12 | belongs_to :user |
13 | + delegate :app, :to => :err | ||
13 | 14 | ||
14 | validates_presence_of :body | 15 | validates_presence_of :body |
15 | 16 |
@@ -0,0 +1,50 @@ | @@ -0,0 +1,50 @@ | ||
1 | +%tr | ||
2 | + %td.section | ||
3 | + %table(cellpadding="0" cellspacing="0" border="0" align="left") | ||
4 | + %tbody | ||
5 | + %tr | ||
6 | + %td.content(valign="top") | ||
7 | + %div | ||
8 | + %p | ||
9 | + = @user.name | ||
10 | + has just commented on an error that occurred in | ||
11 | + = link_to(@app.name, app_url(@app), :class => "bold") << "," | ||
12 | + on the | ||
13 | + %span.bold= @problem.environment | ||
14 | + environment. | ||
15 | + %br | ||
16 | + This err has occurred #{pluralize @problem.notices_count, 'time'}. | ||
17 | + %p | ||
18 | + = link_to("Click here to view the error and add a comment on Errbit", app_problem_url(@app, @problem), :class => "bold") << "." | ||
19 | + | ||
20 | +%tr | ||
21 | + %td.section | ||
22 | + %table(cellpadding="0" cellspacing="0" border="0" align="left") | ||
23 | + %tbody | ||
24 | + %tr | ||
25 | + %td.content(valign="top") | ||
26 | + %div | ||
27 | + %p.heading COMMENT: | ||
28 | + %br | ||
29 | + %p= @comment.body | ||
30 | + | ||
31 | +%tr | ||
32 | + %td.section | ||
33 | + %table(cellpadding="0" cellspacing="0" border="0" align="left") | ||
34 | + %tbody | ||
35 | + %tr | ||
36 | + %td.content(valign="top") | ||
37 | + %div | ||
38 | + %p.heading ERROR MESSAGE: | ||
39 | + %p= @problem.message | ||
40 | + %p.heading WHERE: | ||
41 | + %p.monospace | ||
42 | + = @problem.where | ||
43 | + %p.heading URL: | ||
44 | + %p.monospace | ||
45 | + - if @notice.request['url'].present? | ||
46 | + = link_to @notice.request['url'], @notice.request['url'] | ||
47 | + %p.heading BROWSER: | ||
48 | + %p.monospace | ||
49 | + = user_agent_graph(@problem) | ||
50 | + %br |
@@ -0,0 +1,36 @@ | @@ -0,0 +1,36 @@ | ||
1 | +<%= @user.name %> has just commented on an error that occurred in <%= @notice.environment_name %>: <%= raw(@notice.message) %> | ||
2 | + | ||
3 | +This err has occurred <%= pluralize @notice.problem.notices_count, 'time' %>. You should really look into it here: | ||
4 | + | ||
5 | + <%= app_problem_url(@app, @notice.problem) %> | ||
6 | + | ||
7 | + | ||
8 | +COMMENT: | ||
9 | + | ||
10 | +<%= @comment.body %> | ||
11 | + | ||
12 | + | ||
13 | +----------------------------------------------- | ||
14 | + | ||
15 | +ERROR MESSAGE: | ||
16 | + | ||
17 | +<%= raw(@notice.message) %> | ||
18 | + | ||
19 | + | ||
20 | +WHERE: | ||
21 | + | ||
22 | +<%= @notice.where %> | ||
23 | + | ||
24 | +<% @notice.in_app_backtrace_lines.each do |line| %> | ||
25 | + <%= line %> | ||
26 | +<% end %> | ||
27 | + | ||
28 | + | ||
29 | +URL: | ||
30 | + | ||
31 | +<%= @notice.request['url'] %> | ||
32 | + | ||
33 | + | ||
34 | +BROWSER: | ||
35 | + | ||
36 | +<%= @notice.user_agent_string %> |
config/application.rb
@@ -52,7 +52,7 @@ module Errbit | @@ -52,7 +52,7 @@ module Errbit | ||
52 | config.mongoid.preload_models = true | 52 | config.mongoid.preload_models = true |
53 | 53 | ||
54 | # Set up observers | 54 | # Set up observers |
55 | - config.mongoid.observers = :deploy_observer, :notice_observer | 55 | + config.mongoid.observers = :deploy_observer, :notice_observer, :comment_observer |
56 | 56 | ||
57 | # Configure the default encoding used in templates for Ruby 1.9. | 57 | # Configure the default encoding used in templates for Ruby 1.9. |
58 | config.encoding = "utf-8" | 58 | config.encoding = "utf-8" |