class SubmissionMailer < ApplicationMailer
  def queued(submission)
    @submission = submission
    mail(to: @submission.user.email, subject: 'Submission Received')
  end

  def deposited(submission)
    @submission = submission
    mail(to: @submission.user.email, subject: 'Submission Complete')
  end

  def rejected(submission)
    @submission = submission
    mail(to: @submission.user.email, subject: 'Submission Problem')
  end

  def failed(submission, error)
    @submission = submission
    @error = error
    mail(to: User.where(admin: true).map(&:email),
         subject: 'QuickSubmit: failure')
  end
end

class SubmissionMailer < ApplicationMailer
  def queued(submission)
    return if ENV['DISABLE_ALL_EMAIL']
    @submission = submission
    mail(to: @submission.user.email, subject: 'Submission Received')
  end

  def deposited(submission)
    return if ENV['DISABLE_ALL_EMAIL']
    @submission = submission
    mail(to: @submission.user.email, subject: 'Submission Complete')
  end

  def rejected(submission)
    return if ENV['DISABLE_ALL_EMAIL']
    @submission = submission
    mail(to: @submission.user.email, subject: 'Submission Problem')
  end

  def failed(submission, error)
    return if ENV['DISABLE_ALL_EMAIL']
    @submission = submission
    @error = error
    mail(to: User.where(admin: true).map(&:email),
         subject: 'QuickSubmit: failure')
  end
end

Allow all emails to be disabled
Allow all emails to be disabled

Until sending emails from Heroku is resolved, we need a mechanism to
disable all emails. This might never be merged… we’ll see how long
solving this takes.
