diff options
-rw-r--r-- | app/models/glsa_mailer.rb | 35 | ||||
-rw-r--r-- | app/views/glsa_mailer/approval.erb | 24 | ||||
-rw-r--r-- | app/views/glsa_mailer/comment.erb | 7 | ||||
-rw-r--r-- | app/views/glsa_mailer/text.erb | 4 | ||||
-rw-r--r-- | lib/glsamaker/mail.rb | 46 |
5 files changed, 95 insertions, 21 deletions
diff --git a/app/models/glsa_mailer.rb b/app/models/glsa_mailer.rb index 6649ec4..61db1da 100644 --- a/app/models/glsa_mailer.rb +++ b/app/models/glsa_mailer.rb @@ -18,22 +18,22 @@ class GlsaMailer < ActionMailer::Base body :glsa => glsa, :diff => diff, :user => edit_user end - def comment(sent_at = Time.now) - subject 'GlsaMailer#comment' - recipients '' - from '' - sent_on sent_at + def comment(user, glsa, comment, edit_user) + subject "[GLSAMaker] Draft commented: '#{glsa.last_revision.title}'" + recipients user.email + from GLSAMAKER_FROM_EMAIL + sent_on Time.now - body :greeting => 'Hi,' + body :glsa => glsa, :comment => comment, :user => edit_user end - def approval(sent_at = Time.now) - subject 'GlsaMailer#approval' - recipients '' - from '' - sent_on sent_at - - body :greeting => 'Hi,' + def approval(user, glsa) + subject "[GLSAMaker] Draft approved: '#{glsa.last_revision.title}'" + recipients user.email + from GLSAMAKER_FROM_EMAIL + sent_on Time.now + + body :glsa => glsa end def sent(sent_at = Time.now) @@ -45,4 +45,13 @@ class GlsaMailer < ActionMailer::Base body :greeting => 'Hi,' end + def text(user, _subject, text, footer) + subject _subject + recipients user.email + from GLSAMAKER_FROM_EMAIL + sent_on Time.now + + body :text => text, :footer => footer + end + end diff --git a/app/views/glsa_mailer/approval.erb b/app/views/glsa_mailer/approval.erb index f5bb7ef..4b0e13f 100644 --- a/app/views/glsa_mailer/approval.erb +++ b/app/views/glsa_mailer/approval.erb @@ -1,3 +1,23 @@ -GlsaMailer#approval +Your draft is now approved. -Find me in app/views/glsa_mailer/approval.erb +Approval overview +----------------- +<% @glsa.approvals.each do |approval| -%> +<%= approval.created_at.rfc2822 %> by <%= approval.user.login %> +<% end -%> + +<% if @glsa.rejections.count > 0 -%> +Rejection overview +------------------ +<% @glsa.rejections.each do |rejection| -%> +<%= rejection.created_at.rfc2822 %> by <%= rejection.user.login %> +<% end -%> +<% end -%> + +You should check whether all bugs linked in the draft are in a bug ready state. +Then, you can release the advisory. + +Thanks for your work! + +-- +This email notification is brought to you by GLSAMaker 2.
\ No newline at end of file diff --git a/app/views/glsa_mailer/comment.erb b/app/views/glsa_mailer/comment.erb index 28c3480..2e40122 100644 --- a/app/views/glsa_mailer/comment.erb +++ b/app/views/glsa_mailer/comment.erb @@ -1,3 +1,6 @@ -GlsaMailer#comment +Your draft received a comment (<%= @comment.rating %>) from <%= @user.login %> @ <%= @comment.created_at.rfc2822 %>: -Find me in app/views/glsa_mailer/comment.erb +<%= @comment.text %> + +-- +This email notification is brought to you by GLSAMaker 2.
\ No newline at end of file diff --git a/app/views/glsa_mailer/text.erb b/app/views/glsa_mailer/text.erb new file mode 100644 index 0000000..8279bb9 --- /dev/null +++ b/app/views/glsa_mailer/text.erb @@ -0,0 +1,4 @@ +<%= @text %> +<% if @footer %> +-- +This email notification is brought to you by GLSAMaker 2.<% end %>
\ No newline at end of file diff --git a/lib/glsamaker/mail.rb b/lib/glsamaker/mail.rb index 2d89644..d3ab36b 100644 --- a/lib/glsamaker/mail.rb +++ b/lib/glsamaker/mail.rb @@ -20,7 +20,7 @@ module Glsamaker User.find(:all, :conditions => 'id > 0').each do |rcpt| next unless rcpt.can_access? glsa - unless user.get_pref_category(:mail)[:edit] == false + unless rcpt.get_pref_category(:mail)[:edit] == false GlsaMailer.deliver_edit(rcpt, glsa, diff, user) end end @@ -35,11 +35,49 @@ module Glsamaker User.find(:all, :conditions => 'id > 0').each do |rcpt| next unless rcpt.can_access? glsa - unless user.get_pref_category(:mail)[:request] == false + unless rcpt.get_pref_category(:mail)[:request] == false GlsaMailer.deliver_request(rcpt, glsa, user) end end - end - + end + + def comment_notification(glsa, comment, user) + if GLSAMAKER_NO_EMAIL + Rails.logger.info "Not sending email." + return false + end + + rcpt = glsa.submitter + return unless rcpt.can_access? glsa + return if rcpt == user + + unless rcpt.get_pref_category(:mail)[:comment] == false + GlsaMailer.deliver_comment(rcpt, glsa, comment, user) + end + end + + def approval_notification(glsa) + if GLSAMAKER_NO_EMAIL + Rails.logger.info "Not sending email." + return false + end + + rcpt = glsa.submitter + return unless rcpt.can_access? glsa + + unless rcpt.get_pref_category(:mail)[:comment] == false + GlsaMailer.deliver_approval(rcpt, glsa) + end + end + + def send_text(text, subject, user, footer = true) + if GLSAMAKER_NO_EMAIL + Rails.logger.info "Not sending email." + return false + end + + GlsaMailer.deliver_text(user, subject, text, footer) + end + end end |