send emails for each message in lesson chat

This commit is contained in:
Seth Call 2018-03-05 21:07:30 -06:00
parent 16d8e0fffe
commit 6a4e099a18
2 changed files with 7 additions and 3 deletions

View File

@ -2010,7 +2010,12 @@ module JamRuby
@session_description = @lesson_session.music_session.description @session_description = @lesson_session.music_session.description
@session_date = @lesson_session.slot.pretty_scheduled_start(true) @session_date = @lesson_session.slot.pretty_scheduled_start(true)
@user = @target @user = @target
email = @lesson_session.school_over_teacher if chat_msg.user == chat_msg.lesson_session.student
email = @lesson_session.school_over_teacher
else
email = [chat_msg.lesson_session.student.email]
end
@subject = "#{@sender.name} has sent you a message about a lesson" @subject = "#{@sender.name} has sent you a message about a lesson"
unique_args = {:type => "lesson_chat"} unique_args = {:type => "lesson_chat"}

View File

@ -61,9 +61,8 @@ module JamRuby
lesson_session.save(validate: false) lesson_session.save(validate: false)
# a nil purpose means 'normal chat', which is the only time we should send an email # a nil purpose means 'normal chat', which is the only time we should send an email
if !target.online? && purpose.nil? && message.present? if !target.online? && message.present?
UserMailer.lesson_chat(chat_msg).deliver_now UserMailer.lesson_chat(chat_msg).deliver_now
end end
end end