diff --git a/app/models/journals_for_message_observer.rb b/app/models/journals_for_message_observer.rb index e5fdfb187..093002a2c 100644 --- a/app/models/journals_for_message_observer.rb +++ b/app/models/journals_for_message_observer.rb @@ -1,9 +1,7 @@ # Added by young class JournalsForMessageObserver < ActiveRecord::Observer def after_create(journals_for_message) - Thread.new do Mailer.journals_for_message_add(User.current, journals_for_message).deliver - end end end diff --git a/app/models/mailer.rb b/app/models/mailer.rb index a303d92bf..e0ad54296 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -44,16 +44,7 @@ class Mailer < ActionMailer::Base when :Bid respond_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}") when :Project - if journals_for_message.jour.project_type == 1 - project = journals_for_message.jour - @teachers = searchTeacherAndAssistant journals_for_message.jour - @recipients ||= [] - @teachers.each do |teacher| - @recipients << teacher - end - mail :to => @recipients, - :subject => "您的课程#{journals_for_message.jour.name}中有了新的留言" - end + return -1 if journals_for_message.jour.project_type == Project::ProjectType_project project_feedback_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}") when :Contest show_contest_contest_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}") @@ -63,7 +54,23 @@ class Mailer < ActionMailer::Base logger.error "[Builds a Mail::Message ERROR] journalsForMessage's jour is unkown type, journalsForMessage.id = #{journals_for_message.id}" return -1 end - mail :to => @mail.mail, :subject => @title + #如果是直接留言并且留言对象是Project并且Project类型是课程 + if !journals_for_message.at_user && journals_for_message.jour.class.to_s.to_sym == :Project && journals_for_message.jour.project_type == 1 + project = journals_for_message.jour + #课程的教师 + @teachers = searchTeacherAndAssistant journals_for_message.jour + #收件人邮箱 + @recipients ||= [] + @teachers.each do |teacher| + @recipients << teacher.user.mail + end + mail :to => @recipients, + :subject => "#{l(:label_your_course)}#{journals_for_message.jour.name}#{l(:label_have_message)} " + else + mail :to => @mail.mail, :subject => @title + end + + end # Builds a Mail::Message object used to email recipients of the added issue. @@ -433,7 +440,10 @@ class Mailer < ActionMailer::Base headers[:to].delete(@author.mail) if headers[:to].is_a?(Array) headers[:cc].delete(@author.mail) if headers[:cc].is_a?(Array) end - + if !User.current.nil? + #不给本人发邮件 + headers[:to].delete(User.current.mail) if headers[:to].is_a?(Array) + end if @author && @author.logged? redmine_headers 'Sender' => @author.login end diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 48cc16c6e..aa4140f95 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -57,7 +57,7 @@