diff options
-rw-r--r-- | app/mailers/notify.rb | 8 | ||||
-rw-r--r-- | app/models/mailer_observer.rb | 13 | ||||
-rw-r--r-- | app/views/notify/changed_issue_email.html.haml | 16 | ||||
-rw-r--r-- | app/views/notify/new_issue_email.html.haml | 2 |
4 files changed, 38 insertions, 1 deletions
diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb index cbc895465b0..02ea1101683 100644 --- a/app/mailers/notify.rb +++ b/app/mailers/notify.rb @@ -53,4 +53,12 @@ class Notify < ActionMailer::Base @project = merge_request.project mail(:to => @user.email, :subject => "gitlab | #{@merge_request.title} ") end + + def changed_issue_email(user, issue) + @user = user + @assignee_was ||= User.find(issue.assignee_id_was) + @issue = issue + @project = issue.project + mail(:to => @user.email, :subject => "gitlab | #{@issue.title} ") + end end diff --git a/app/models/mailer_observer.rb b/app/models/mailer_observer.rb index 39081fdae04..19ecb4f3b54 100644 --- a/app/models/mailer_observer.rb +++ b/app/models/mailer_observer.rb @@ -11,6 +11,7 @@ class MailerObserver < ActiveRecord::Observer def after_update(model) changed_merge_request(model) if model.kind_of?(MergeRequest) + changed_issue(model) if model.kind_of?(Issue) end protected @@ -61,4 +62,16 @@ class MailerObserver < ActiveRecord::Observer end end + def changed_issue(issue) + if issue.assignee_id_changed? + recipients_ids = [issue.assignee_id_was] + recipients_ids << issue.assignee_id + recipients_ids.delete current_user.id + + User.find(recipients_ids).each do |user| + Notify.changed_issue_email(user, issue).deliver + end + end + + end end diff --git a/app/views/notify/changed_issue_email.html.haml b/app/views/notify/changed_issue_email.html.haml new file mode 100644 index 00000000000..fe046e408a1 --- /dev/null +++ b/app/views/notify/changed_issue_email.html.haml @@ -0,0 +1,16 @@ +%td.content{:align => "left", :style => "font-family: Helvetica, Arial, sans-serif; padding: 20px 0 0;", :valign => "top", :width => "600"} + %table{:border => "0", :cellpadding => "0", :cellspacing => "0", :style => "color: #717171; font: normal 11px Helvetica, Arial, sans-serif; margin: 0; padding: 0;", :width => "600"} + %tr + %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"} + %td{:align => "left", :style => "padding: 20px 0 0;"} + %h2{:style => "color:#646464; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "} + Reassigned Issue + = link_to truncate(@issue.title, :length => 16), project_issue_url(@project, @issue) + %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"} + %tr + %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"} + %td{:style => "padding: 15px 0 15px;", :valign => "top"} + %p{:style => "color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 20px; font-size: 12px;font-family: Helvetica, Arial, sans-serif; "} + Assignee changed from #{@assignee_was.name} to #{@issue.assignee.name} + %td + diff --git a/app/views/notify/new_issue_email.html.haml b/app/views/notify/new_issue_email.html.haml index c411d9dc943..64c5aa611eb 100644 --- a/app/views/notify/new_issue_email.html.haml +++ b/app/views/notify/new_issue_email.html.haml @@ -4,7 +4,7 @@ %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"} %td{:align => "left", :style => "padding: 20px 0 0;"} %h2{:style => "color:#646464; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "} - Hi #{@user.name}! New Issue was created and assigned to you. + New Issue was created and assigned to you. %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"} %tr %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"} |