Commit 32aa2e3f24c1b2d1d3f4fa8cfb6334644492ba2a
1 parent
df5b192e
Exists in
master
and in
4 other branches
notification when assignee issue changed
Showing
4 changed files
with
38 additions
and
1 deletions
Show diff stats
app/mailers/notify.rb
| ... | ... | @@ -53,4 +53,12 @@ class Notify < ActionMailer::Base |
| 53 | 53 | @project = merge_request.project |
| 54 | 54 | mail(:to => @user.email, :subject => "gitlab | #{@merge_request.title} ") |
| 55 | 55 | end |
| 56 | + | |
| 57 | + def changed_issue_email(user, issue) | |
| 58 | + @user = user | |
| 59 | + @assignee_was ||= User.find(issue.assignee_id_was) | |
| 60 | + @issue = issue | |
| 61 | + @project = issue.project | |
| 62 | + mail(:to => @user.email, :subject => "gitlab | #{@issue.title} ") | |
| 63 | + end | |
| 56 | 64 | end | ... | ... |
app/models/mailer_observer.rb
| ... | ... | @@ -11,6 +11,7 @@ class MailerObserver < ActiveRecord::Observer |
| 11 | 11 | |
| 12 | 12 | def after_update(model) |
| 13 | 13 | changed_merge_request(model) if model.kind_of?(MergeRequest) |
| 14 | + changed_issue(model) if model.kind_of?(Issue) | |
| 14 | 15 | end |
| 15 | 16 | |
| 16 | 17 | protected |
| ... | ... | @@ -61,4 +62,16 @@ class MailerObserver < ActiveRecord::Observer |
| 61 | 62 | end |
| 62 | 63 | end |
| 63 | 64 | |
| 65 | + def changed_issue(issue) | |
| 66 | + if issue.assignee_id_changed? | |
| 67 | + recipients_ids = [issue.assignee_id_was] | |
| 68 | + recipients_ids << issue.assignee_id | |
| 69 | + recipients_ids.delete current_user.id | |
| 70 | + | |
| 71 | + User.find(recipients_ids).each do |user| | |
| 72 | + Notify.changed_issue_email(user, issue).deliver | |
| 73 | + end | |
| 74 | + end | |
| 75 | + | |
| 76 | + end | |
| 64 | 77 | end | ... | ... |
| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | +%td.content{:align => "left", :style => "font-family: Helvetica, Arial, sans-serif; padding: 20px 0 0;", :valign => "top", :width => "600"} | |
| 2 | + %table{:border => "0", :cellpadding => "0", :cellspacing => "0", :style => "color: #717171; font: normal 11px Helvetica, Arial, sans-serif; margin: 0; padding: 0;", :width => "600"} | |
| 3 | + %tr | |
| 4 | + %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"} | |
| 5 | + %td{:align => "left", :style => "padding: 20px 0 0;"} | |
| 6 | + %h2{:style => "color:#646464; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "} | |
| 7 | + Reassigned Issue | |
| 8 | + = link_to truncate(@issue.title, :length => 16), project_issue_url(@project, @issue) | |
| 9 | + %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"} | |
| 10 | + %tr | |
| 11 | + %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"} | |
| 12 | + %td{:style => "padding: 15px 0 15px;", :valign => "top"} | |
| 13 | + %p{:style => "color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 20px; font-size: 12px;font-family: Helvetica, Arial, sans-serif; "} | |
| 14 | + Assignee changed from #{@assignee_was.name} to #{@issue.assignee.name} | |
| 15 | + %td | |
| 16 | + | ... | ... |
app/views/notify/new_issue_email.html.haml
| ... | ... | @@ -4,7 +4,7 @@ |
| 4 | 4 | %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"} |
| 5 | 5 | %td{:align => "left", :style => "padding: 20px 0 0;"} |
| 6 | 6 | %h2{:style => "color:#646464; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "} |
| 7 | - Hi #{@user.name}! New Issue was created and assigned to you. | |
| 7 | + New Issue was created and assigned to you. | |
| 8 | 8 | %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"} |
| 9 | 9 | %tr |
| 10 | 10 | %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"} | ... | ... |