diff --git a/app/jobs/conversation_reply_email_job.rb b/app/jobs/conversation_reply_email_job.rb index 9d4c120c8..d3c4a1d81 100644 --- a/app/jobs/conversation_reply_email_job.rb +++ b/app/jobs/conversation_reply_email_job.rb @@ -4,6 +4,7 @@ class ConversationReplyEmailJob < ApplicationJob def perform(conversation_id, last_queued_id) conversation = Conversation.find(conversation_id) return unless conversation.account.active? + return unless conversation.inbox.active? if conversation.messages.incoming&.last&.content_type == 'incoming_email' ConversationReplyMailer.with(account: conversation.account).reply_without_summary(conversation, last_queued_id).deliver_later diff --git a/spec/jobs/conversation_reply_email_job_spec.rb b/spec/jobs/conversation_reply_email_job_spec.rb index 32758c48e..c9c13e96a 100644 --- a/spec/jobs/conversation_reply_email_job_spec.rb +++ b/spec/jobs/conversation_reply_email_job_spec.rb @@ -30,4 +30,12 @@ RSpec.describe ConversationReplyEmailJob, type: :job do described_class.perform_now(conversation.id, 123) expect(mailer).to have_received(:reply_without_summary) end + + it 'does not send an email when the inbox is disabled before the job runs' do + conversation.inbox.update!(active: false) + + described_class.perform_now(conversation.id, 123) + + expect(ConversationReplyMailer).not_to have_received(:with) + end end